Skip to content

Commit 309c082

Browse files
committed
specify FES i18n in one line
1 parent 3887266 commit 309c082

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/internationalization.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import i18next from 'i18next';
22
import LanguageDetector from 'i18next-browser-languagedetector';
3-
import * as constants from './constants';
3+
import { VERSION } from './constants';
44

55

66
let fallbackResources, languages;
@@ -129,7 +129,6 @@ export let translator = (key, values) => {
129129
* Set up our translation function, with loaded languages
130130
*/
131131
export const initialize = () => {
132-
let latestMinorVersionPath = 'https://cdn.jsdelivr.net/npm/p5@' + constants.VERSION.replace(/^(\d+\.\d+)\.\d+.*$/, '$1');
133132
let i18init = i18next
134133
.use(LanguageDetector)
135134
.use(FetchResources)
@@ -152,7 +151,12 @@ export const initialize = () => {
152151
},
153152
backend: {
154153
fallback: 'en',
155-
loadPath: latestMinorVersionPath + '/translations/{{lng}}/{{ns}}.json'
154+
155+
// ensure that the FES internationalization strings are loaded
156+
// from the latest patch of the current minor version of p5.js
157+
loadPath: `https://cdn.jsdelivr.net/npm/p5@${
158+
VERSION.replace(/^(\d+\.\d+)\.\d+.*$/, '$1')
159+
}/translations/{{lng}}/{{ns}}.json`
156160
},
157161
partialBundledLanguages: true,
158162
resources: fallbackResources

0 commit comments

Comments
 (0)