From 8b3017bca08a8178e03ed4a43ec614125db975a4 Mon Sep 17 00:00:00 2001 From: surfdude29 <149612116+surfdude29@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:51:54 +0100 Subject: [PATCH] Alphabetise languages by language code (#3350) * Alphabetise languages in lingui.config.js * Alphabetise languages in helpers.ts * Alphabetise languages in i18n.ts * Alphabetise languages in i18n.ts * Alphabetise languages in i18n.web.ts * Alphabetise languages in languages.ts --- lingui.config.js | 6 +++--- src/locale/helpers.ts | 12 ++++++------ src/locale/i18n.ts | 24 ++++++++++++------------ src/locale/i18n.web.ts | 24 ++++++++++++------------ src/locale/languages.ts | 18 +++++++++--------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lingui.config.js b/lingui.config.js index b8e0da7bfc..14a94b5ded 100644 --- a/lingui.config.js +++ b/lingui.config.js @@ -2,6 +2,7 @@ module.exports = { locales: [ 'en', + 'ca', 'de', 'es', 'fi', @@ -9,15 +10,14 @@ module.exports = { 'ga', 'hi', 'id', + 'it', 'ja', 'ko', 'pt-BR', + 'tr', 'uk', - 'ca', 'zh-CN', 'zh-TW', - 'it', - 'tr', ], catalogs: [ { diff --git a/src/locale/helpers.ts b/src/locale/helpers.ts index 889de1ecd3..24ab678934 100644 --- a/src/locale/helpers.ts +++ b/src/locale/helpers.ts @@ -119,6 +119,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage { switch (lang) { case 'en': return AppLanguage.en + case 'ca': + return AppLanguage.ca case 'de': return AppLanguage.de case 'es': @@ -133,24 +135,22 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage { return AppLanguage.hi case 'id': return AppLanguage.id + case 'it': + return AppLanguage.it case 'ja': return AppLanguage.ja case 'ko': return AppLanguage.ko case 'pt-BR': return AppLanguage.pt_BR + case 'tr': + return AppLanguage.tr case 'uk': return AppLanguage.uk - case 'ca': - return AppLanguage.ca case 'zh-CN': return AppLanguage.zh_CN case 'zh-TW': return AppLanguage.zh_TW - case 'it': - return AppLanguage.it - case 'tr': - return AppLanguage.tr default: continue } diff --git a/src/locale/i18n.ts b/src/locale/i18n.ts index e2cda40aaf..725332de01 100644 --- a/src/locale/i18n.ts +++ b/src/locale/i18n.ts @@ -27,6 +27,10 @@ import {useLanguagePrefs} from '#/state/preferences' */ export async function dynamicActivate(locale: AppLanguage) { switch (locale) { + case AppLanguage.ca: { + i18n.loadAndActivate({locale, messages: messagesCa}) + break + } case AppLanguage.de: { i18n.loadAndActivate({locale, messages: messagesDe}) break @@ -55,6 +59,10 @@ export async function dynamicActivate(locale: AppLanguage) { i18n.loadAndActivate({locale, messages: messagesId}) break } + case AppLanguage.it: { + i18n.loadAndActivate({locale, messages: messagesIt}) + break + } case AppLanguage.ja: { i18n.loadAndActivate({locale, messages: messagesJa}) break @@ -67,30 +75,22 @@ export async function dynamicActivate(locale: AppLanguage) { i18n.loadAndActivate({locale, messages: messagesPt_BR}) break } - case AppLanguage.uk: { - i18n.loadAndActivate({locale, messages: messagesUk}) + case AppLanguage.tr: { + i18n.loadAndActivate({locale, messages: messagesTr}) break } - case AppLanguage.ca: { - i18n.loadAndActivate({locale, messages: messagesCa}) + case AppLanguage.uk: { + i18n.loadAndActivate({locale, messages: messagesUk}) break } case AppLanguage.zh_CN: { i18n.loadAndActivate({locale, messages: messagesZh_CN}) break } - case AppLanguage.it: { - i18n.loadAndActivate({locale, messages: messagesIt}) - break - } case AppLanguage.zh_TW: { i18n.loadAndActivate({locale, messages: messagesZh_TW}) break } - case AppLanguage.tr: { - i18n.loadAndActivate({locale, messages: messagesTr}) - break - } default: { i18n.loadAndActivate({locale, messages: messagesEn}) break diff --git a/src/locale/i18n.web.ts b/src/locale/i18n.web.ts index fdfa7301d3..87c3c590e9 100644 --- a/src/locale/i18n.web.ts +++ b/src/locale/i18n.web.ts @@ -12,6 +12,10 @@ export async function dynamicActivate(locale: AppLanguage) { let mod: any switch (locale) { + case AppLanguage.ca: { + mod = await import(`./locales/ca/messages`) + break + } case AppLanguage.de: { mod = await import(`./locales/de/messages`) break @@ -40,6 +44,10 @@ export async function dynamicActivate(locale: AppLanguage) { mod = await import(`./locales/id/messages`) break } + case AppLanguage.it: { + mod = await import(`./locales/it/messages`) + break + } case AppLanguage.ja: { mod = await import(`./locales/ja/messages`) break @@ -52,12 +60,12 @@ export async function dynamicActivate(locale: AppLanguage) { mod = await import(`./locales/pt-BR/messages`) break } - case AppLanguage.uk: { - mod = await import(`./locales/uk/messages`) + case AppLanguage.tr: { + mod = await import(`./locales/tr/messages`) break } - case AppLanguage.ca: { - mod = await import(`./locales/ca/messages`) + case AppLanguage.uk: { + mod = await import(`./locales/uk/messages`) break } case AppLanguage.zh_CN: { @@ -68,14 +76,6 @@ export async function dynamicActivate(locale: AppLanguage) { mod = await import(`./locales/zh-TW/messages`) break } - case AppLanguage.it: { - mod = await import(`./locales/it/messages`) - break - } - case AppLanguage.tr: { - mod = await import(`./locales/tr/messages`) - break - } default: { mod = await import(`./locales/en/messages`) break diff --git a/src/locale/languages.ts b/src/locale/languages.ts index 60b0b73232..626c00f389 100644 --- a/src/locale/languages.ts +++ b/src/locale/languages.ts @@ -6,6 +6,7 @@ interface Language { export enum AppLanguage { en = 'en', + ca = 'ca', de = 'de', es = 'es', fi = 'fi', @@ -13,15 +14,14 @@ export enum AppLanguage { ga = 'ga', hi = 'hi', id = 'id', + it = 'it', ja = 'ja', ko = 'ko', pt_BR = 'pt-BR', + tr = 'tr', uk = 'uk', - ca = 'ca', zh_CN = 'zh-CN', zh_TW = 'zh-TW', - it = 'it', - tr = 'tr', } interface AppLanguageConfig { @@ -31,22 +31,22 @@ interface AppLanguageConfig { export const APP_LANGUAGES: AppLanguageConfig[] = [ {code2: AppLanguage.en, name: 'English'}, + {code2: AppLanguage.ca, name: 'Català – Catalan'}, {code2: AppLanguage.de, name: 'Deutsch – German'}, {code2: AppLanguage.es, name: 'Español – Spanish'}, {code2: AppLanguage.fi, name: 'Suomi – Finnish'}, {code2: AppLanguage.fr, name: 'Français – French'}, - {code2: AppLanguage.ga, name: 'Gaeilge - Irish'}, + {code2: AppLanguage.ga, name: 'Gaeilge – Irish'}, {code2: AppLanguage.hi, name: 'हिंदी – Hindi'}, {code2: AppLanguage.id, name: 'Bahasa Indonesia – Indonesian'}, + {code2: AppLanguage.it, name: 'Italiano – Italian'}, {code2: AppLanguage.ja, name: '日本語 – Japanese'}, {code2: AppLanguage.ko, name: '한국어 – Korean'}, {code2: AppLanguage.pt_BR, name: 'Português (BR) – Portuguese (BR)'}, + {code2: AppLanguage.tr, name: 'Türkçe – Turkish'}, {code2: AppLanguage.uk, name: 'Українська – Ukrainian'}, - {code2: AppLanguage.ca, name: 'Català – Catalan'}, - {code2: AppLanguage.zh_CN, name: '简体中文(中国) – Chinese (Simplified)'}, - {code2: AppLanguage.zh_TW, name: '繁體中文(臺灣) – Chinese (Traditional)'}, - {code2: AppLanguage.it, name: 'Italiano - Italian'}, - {code2: AppLanguage.tr, name: 'Türkçe - Turkish'}, + {code2: AppLanguage.zh_CN, name: '简体中文(中国)– Chinese (Simplified)'}, + {code2: AppLanguage.zh_TW, name: '繁體中文(臺灣)– Chinese (Traditional)'}, ] export const LANGUAGES: Language[] = [