Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily filter out extra languages in release mode #654

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions app/locales/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ export async function setUserLocaleOverride(locale) {
await SetStoreData(LANG_OVERRIDE, locale);
}

/** Languages only available in dev builds. */
const DEV_LANGUAGES = __DEV__
? {
ar: { label: 'العربية', translation: ar },
es: { label: 'Español', translation: es },
fr: { label: 'Français', translation: fr },
id: { label: 'Indonesia', translation: id },
it: { label: 'Italiano', translation: it },
ml: { label: 'മലയാളം', translation: ml },
nl: { label: 'Nederlands', translation: nl },
pl: { label: 'Polski', translation: pl },
ro: { label: 'Română', translation: ro },
ru: { label: 'Русский', translation: ru },
sk: { label: 'Slovak', translation: sk },
vi: { label: 'Vietnamese', translation: vi },
zh_Hant: { label: '繁體中文', translation: zh_Hant },
}
: {};

i18next.use(initReactI18next).init({
interpolation: {
// React already does escaping
Expand All @@ -81,31 +100,19 @@ i18next.use(initReactI18next).init({
fallbackLng: 'en', // If language detector fails
returnEmptyString: false,
resources: {
ar: { label: 'العربية', translation: ar },
en: { label: 'English', translation: en },
es: { label: 'Español', translation: es },
fr: { label: 'Français', translation: fr },
ht: { label: 'Kreyòl ayisyen', translation: ht },
id: { label: 'Indonesia', translation: id },
it: { label: 'Italiano', translation: it },
ml: { label: 'മലയാളം', translation: ml },
nl: { label: 'Nederlands', translation: nl },
pl: { label: 'Polski', translation: pl },
ro: { label: 'Română', translation: ro },
ru: { label: 'Русский', translation: ru },
sk: { label: 'Slovak', translation: sk },
vi: { label: 'Vietnamese', translation: vi },
zh_Hant: { label: '繁體中文', translation: zh_Hant },
...DEV_LANGUAGES,
},
});

/** The known locale list */
export const LOCALE_LIST = Object.entries(i18next.options.resources).map(
([langCode, lang]) => ({
export const LOCALE_LIST = Object.entries(i18next.options.resources)
.map(([langCode, lang]) => ({
value: langCode,
label: lang.label,
}),
);
}))
.sort((a, b) => a.value > b.value);

/** A map of locale code to name. */
export const LOCALE_NAME = Object.entries(i18next.options.resources).reduce(
Expand Down