()
| 126 | * @private |
| 127 | */ |
| 128 | export const initialize = () => { |
| 129 | let i18init = i18next |
| 130 | .use(LanguageDetector) |
| 131 | .use(FetchResources) |
| 132 | .init({ |
| 133 | fallbackLng: 'en', |
| 134 | nestingPrefix: '$tr(', |
| 135 | nestingSuffix: ')', |
| 136 | defaultNS: 'translation', |
| 137 | returnEmptyString: false, |
| 138 | interpolation: { |
| 139 | escapeValue: false |
| 140 | }, |
| 141 | detection: { |
| 142 | checkWhitelist: false, |
| 143 | |
| 144 | // prevent storing or locating language from cookie or localStorage |
| 145 | // more info on https://github.com/processing/p5.js/issues/4862 |
| 146 | order: ['querystring', 'navigator', 'htmlTag', 'path', 'subdomain'], |
| 147 | caches: [] |
| 148 | }, |
| 149 | backend: { |
| 150 | fallback: 'en', |
| 151 | |
| 152 | // ensure that the FES internationalization strings are loaded |
| 153 | // from the latest patch of the current minor version of p5.js |
| 154 | loadPath: `https://cdn.jsdelivr.net/npm/p5@${ |
| 155 | VERSION.replace(/^(\d+\.\d+)\.\d+.*$/, '$1') |
| 156 | }/translations/{{lng}}/{{ns}}.json` |
| 157 | }, |
| 158 | partialBundledLanguages: true, |
| 159 | resources: fallbackResources |
| 160 | }) |
| 161 | .then( |
| 162 | translateFn => { |
| 163 | translator = translateFn; |
| 164 | }, |
| 165 | e => console.debug(`Translations failed to load (${e})`) |
| 166 | ); |
| 167 | |
| 168 | // i18next.init() returns a promise that resolves when the translations |
| 169 | // are loaded. We use this in core/init.js to hold p5 initialization until |
| 170 | // we have the translation files. |
| 171 | return i18init; |
| 172 | }; |
| 173 | |
| 174 | /* |
| 175 | * Returns a list of languages we have translations loaded for |
no test coverage detected