MCPcopy Index your code
hub / github.com/MagicMirrorOrg/MagicMirror / loadTranslations

Method loadTranslations

js/module.js:300–323  ·  view source on GitHub ↗

* Load all translations. * @returns {Promise }

()

Source from the content-addressed store, hash-verified

298 * @returns {Promise<void>}
299 */
300 async loadTranslations () {
301 const translations = this.getTranslations() || {};
302 const language = config.language.toLowerCase();
303
304 const languages = Object.keys(translations);
305 const fallbackLanguage = languages[0];
306
307 if (languages.length === 0) {
308 return;
309 }
310
311 const translationFile = translations[language];
312 const translationsFallbackFile = translations[fallbackLanguage];
313
314 if (!translationFile) {
315 return Translator.load(this, translationsFallbackFile, true);
316 }
317
318 await Translator.load(this, translationFile, false);
319
320 if (translationFile !== translationsFallbackFile) {
321 return Translator.load(this, translationsFallbackFile, true);
322 }
323 }
324
325 /**
326 * Request the translation for a given key with optional variables and default value.

Callers 2

bootstrapModuleFunction · 0.80

Calls 1

getTranslationsMethod · 0.95

Tested by

no test coverage detected