* Load all translations. * @returns {Promise }
()
| 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. |
no test coverage detected