From c116819376f38166a4f930f6c76e70c7ab839f52 Mon Sep 17 00:00:00 2001 From: Tim Stirrat Date: Thu, 23 Apr 2020 16:16:35 -0700 Subject: [PATCH 1/2] Temporarily filter out extra languages in release mode --- app/locales/languages.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/locales/languages.js b/app/locales/languages.js index 26161119f8..f5b0b0ea22 100644 --- a/app/locales/languages.js +++ b/app/locales/languages.js @@ -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 @@ -81,21 +100,9 @@ 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, }, }); From 86304817448281742d25f4b65eadf1876c19b359 Mon Sep 17 00:00:00 2001 From: Tim Stirrat Date: Thu, 23 Apr 2020 16:26:46 -0700 Subject: [PATCH 2/2] sort the language list on code, like before --- app/locales/languages.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/locales/languages.js b/app/locales/languages.js index f5b0b0ea22..36e391e64c 100644 --- a/app/locales/languages.js +++ b/app/locales/languages.js @@ -107,12 +107,12 @@ i18next.use(initReactI18next).init({ }); /** 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(