lbry-desktop/ui/constants/supported_languages.js
infinite-persistence 81e4730037 Simplify language lists
- SUPPORTED_SUB_LANGUAGE_CODES[] that I introduced was pretty redundant when SUPPORTED_LANGUAGES[] already hold the information. The logic to ignore sub-languages (i.e. reduce the locale's "en-GB" to "en" is now located in getDefaultLanguage()).

- SUPPORTED_BROWSER_LANGUAGES[] and SUPPORTED_LANGUAGES[] look so similar and hard to tell what the former is for at first glance. The functionality to map 'zh-CN' to 'zh-Hans' is now handled by resolveLanguageAlias(), which makes the intention clearer.

This leaves us with a single list -- SUPPORTED_LANGUAGES[], whose key also tells us the desired language code to use.
Also, clients now need to call `resolveLanguageAlias` to map any language code aliases, as they differ depending on how it is queried (e.g. `navigator.language` vs. `app.getLocal()` uses different standards).

I think we no longer need to explicitly migrate existing user's 'zh-CN' into 'zh-Hans' because the rest of the system will always use the desired language code as long as 'resolveLanguageAlias' is called appropriately. e.g. the system uses `selectLanguage` and `selectLanguage` calls `resolveLanguageAlias`.
2021-04-04 22:54:33 -04:00

42 lines
1,004 B
JavaScript

import LANGUAGES from './languages';
const SUPPORTED_LANGUAGES = {
en: LANGUAGES.en[1],
da: LANGUAGES.da[1],
'zh-Hans': LANGUAGES['zh-Hans'][1],
'zh-Hant': LANGUAGES['zh-Hant'][1],
hr: LANGUAGES.hr[1],
nl: LANGUAGES.nl[1],
no: LANGUAGES.no[1],
fi: LANGUAGES.fi[1],
fr: LANGUAGES.fr[1],
de: LANGUAGES.de[1],
gu: LANGUAGES.gu[1],
hi: LANGUAGES.hi[1],
id: LANGUAGES.id[1],
jv: LANGUAGES.jv[1],
it: LANGUAGES.it[1],
ms: LANGUAGES.ms[1],
ml: LANGUAGES.ml[1],
mr: LANGUAGES.mr[1],
pa: LANGUAGES.pa[1],
pl: LANGUAGES.pl[1],
pt: LANGUAGES.pt[1],
ro: LANGUAGES.ro[1],
ru: LANGUAGES.ru[1],
sr: LANGUAGES.sr[1],
sk: LANGUAGES.sk[1],
ur: LANGUAGES.ur[1],
ca: LANGUAGES.ca[1],
es: LANGUAGES.es[1],
sv: LANGUAGES.sv[1],
tr: LANGUAGES.tr[1],
cs: LANGUAGES.cs[1],
kn: LANGUAGES.kn[1],
uk: LANGUAGES.uk[1],
};
// Properties: language code (e.g. 'ja')
// Values: name of the language in native form (e.g. '日本語')
export default SUPPORTED_LANGUAGES;