(language, script_path)
| 18 | */ |
| 19 | class Language { |
| 20 | constructor(language, script_path) { |
| 21 | // borrowed from http://stackoverflow.com/a/14446414/102476 |
| 22 | for (let k in LANGUAGES.en) { |
| 23 | this[k] = LANGUAGES.en[k]; |
| 24 | } |
| 25 | // `language` won't be defined when the fallback is constructed |
| 26 | if (language && typeof(language) == 'string' && language != 'en') { |
| 27 | var code = language; |
| 28 | if (!(code in LANGUAGES)) { |
| 29 | console.log(`Expected language ${code} to be cached. Did you call the constructor directly?`) |
| 30 | var url = buildLanguageURL(code, script_path); |
| 31 | fetchJSON(url).then((json) => { |
| 32 | LANGUAGES[code] = json |
| 33 | }).catch(resp => { |
| 34 | console.log(`Error loading language [${url}] ${resp.statusText} [${resp.status}]`) |
| 35 | }) |
| 36 | } |
| 37 | mergeData(this, LANGUAGES[code]); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Reimplement Util.mergeData to handle nested dictionaries |
nothing calls this directly
no test coverage detected