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
zio/stable
surfdude29 2024-04-04 18:51:54 +01:00 committed by GitHub
parent 51e939ed3d
commit 8b3017bca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 42 deletions

View File

@ -2,6 +2,7 @@
module.exports = { module.exports = {
locales: [ locales: [
'en', 'en',
'ca',
'de', 'de',
'es', 'es',
'fi', 'fi',
@ -9,15 +10,14 @@ module.exports = {
'ga', 'ga',
'hi', 'hi',
'id', 'id',
'it',
'ja', 'ja',
'ko', 'ko',
'pt-BR', 'pt-BR',
'tr',
'uk', 'uk',
'ca',
'zh-CN', 'zh-CN',
'zh-TW', 'zh-TW',
'it',
'tr',
], ],
catalogs: [ catalogs: [
{ {

View File

@ -119,6 +119,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
switch (lang) { switch (lang) {
case 'en': case 'en':
return AppLanguage.en return AppLanguage.en
case 'ca':
return AppLanguage.ca
case 'de': case 'de':
return AppLanguage.de return AppLanguage.de
case 'es': case 'es':
@ -133,24 +135,22 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
return AppLanguage.hi return AppLanguage.hi
case 'id': case 'id':
return AppLanguage.id return AppLanguage.id
case 'it':
return AppLanguage.it
case 'ja': case 'ja':
return AppLanguage.ja return AppLanguage.ja
case 'ko': case 'ko':
return AppLanguage.ko return AppLanguage.ko
case 'pt-BR': case 'pt-BR':
return AppLanguage.pt_BR return AppLanguage.pt_BR
case 'tr':
return AppLanguage.tr
case 'uk': case 'uk':
return AppLanguage.uk return AppLanguage.uk
case 'ca':
return AppLanguage.ca
case 'zh-CN': case 'zh-CN':
return AppLanguage.zh_CN return AppLanguage.zh_CN
case 'zh-TW': case 'zh-TW':
return AppLanguage.zh_TW return AppLanguage.zh_TW
case 'it':
return AppLanguage.it
case 'tr':
return AppLanguage.tr
default: default:
continue continue
} }

View File

@ -27,6 +27,10 @@ import {useLanguagePrefs} from '#/state/preferences'
*/ */
export async function dynamicActivate(locale: AppLanguage) { export async function dynamicActivate(locale: AppLanguage) {
switch (locale) { switch (locale) {
case AppLanguage.ca: {
i18n.loadAndActivate({locale, messages: messagesCa})
break
}
case AppLanguage.de: { case AppLanguage.de: {
i18n.loadAndActivate({locale, messages: messagesDe}) i18n.loadAndActivate({locale, messages: messagesDe})
break break
@ -55,6 +59,10 @@ export async function dynamicActivate(locale: AppLanguage) {
i18n.loadAndActivate({locale, messages: messagesId}) i18n.loadAndActivate({locale, messages: messagesId})
break break
} }
case AppLanguage.it: {
i18n.loadAndActivate({locale, messages: messagesIt})
break
}
case AppLanguage.ja: { case AppLanguage.ja: {
i18n.loadAndActivate({locale, messages: messagesJa}) i18n.loadAndActivate({locale, messages: messagesJa})
break break
@ -67,30 +75,22 @@ export async function dynamicActivate(locale: AppLanguage) {
i18n.loadAndActivate({locale, messages: messagesPt_BR}) i18n.loadAndActivate({locale, messages: messagesPt_BR})
break break
} }
case AppLanguage.uk: { case AppLanguage.tr: {
i18n.loadAndActivate({locale, messages: messagesUk}) i18n.loadAndActivate({locale, messages: messagesTr})
break break
} }
case AppLanguage.ca: { case AppLanguage.uk: {
i18n.loadAndActivate({locale, messages: messagesCa}) i18n.loadAndActivate({locale, messages: messagesUk})
break break
} }
case AppLanguage.zh_CN: { case AppLanguage.zh_CN: {
i18n.loadAndActivate({locale, messages: messagesZh_CN}) i18n.loadAndActivate({locale, messages: messagesZh_CN})
break break
} }
case AppLanguage.it: {
i18n.loadAndActivate({locale, messages: messagesIt})
break
}
case AppLanguage.zh_TW: { case AppLanguage.zh_TW: {
i18n.loadAndActivate({locale, messages: messagesZh_TW}) i18n.loadAndActivate({locale, messages: messagesZh_TW})
break break
} }
case AppLanguage.tr: {
i18n.loadAndActivate({locale, messages: messagesTr})
break
}
default: { default: {
i18n.loadAndActivate({locale, messages: messagesEn}) i18n.loadAndActivate({locale, messages: messagesEn})
break break

View File

@ -12,6 +12,10 @@ export async function dynamicActivate(locale: AppLanguage) {
let mod: any let mod: any
switch (locale) { switch (locale) {
case AppLanguage.ca: {
mod = await import(`./locales/ca/messages`)
break
}
case AppLanguage.de: { case AppLanguage.de: {
mod = await import(`./locales/de/messages`) mod = await import(`./locales/de/messages`)
break break
@ -40,6 +44,10 @@ export async function dynamicActivate(locale: AppLanguage) {
mod = await import(`./locales/id/messages`) mod = await import(`./locales/id/messages`)
break break
} }
case AppLanguage.it: {
mod = await import(`./locales/it/messages`)
break
}
case AppLanguage.ja: { case AppLanguage.ja: {
mod = await import(`./locales/ja/messages`) mod = await import(`./locales/ja/messages`)
break break
@ -52,12 +60,12 @@ export async function dynamicActivate(locale: AppLanguage) {
mod = await import(`./locales/pt-BR/messages`) mod = await import(`./locales/pt-BR/messages`)
break break
} }
case AppLanguage.uk: { case AppLanguage.tr: {
mod = await import(`./locales/uk/messages`) mod = await import(`./locales/tr/messages`)
break break
} }
case AppLanguage.ca: { case AppLanguage.uk: {
mod = await import(`./locales/ca/messages`) mod = await import(`./locales/uk/messages`)
break break
} }
case AppLanguage.zh_CN: { case AppLanguage.zh_CN: {
@ -68,14 +76,6 @@ export async function dynamicActivate(locale: AppLanguage) {
mod = await import(`./locales/zh-TW/messages`) mod = await import(`./locales/zh-TW/messages`)
break break
} }
case AppLanguage.it: {
mod = await import(`./locales/it/messages`)
break
}
case AppLanguage.tr: {
mod = await import(`./locales/tr/messages`)
break
}
default: { default: {
mod = await import(`./locales/en/messages`) mod = await import(`./locales/en/messages`)
break break

View File

@ -6,6 +6,7 @@ interface Language {
export enum AppLanguage { export enum AppLanguage {
en = 'en', en = 'en',
ca = 'ca',
de = 'de', de = 'de',
es = 'es', es = 'es',
fi = 'fi', fi = 'fi',
@ -13,15 +14,14 @@ export enum AppLanguage {
ga = 'ga', ga = 'ga',
hi = 'hi', hi = 'hi',
id = 'id', id = 'id',
it = 'it',
ja = 'ja', ja = 'ja',
ko = 'ko', ko = 'ko',
pt_BR = 'pt-BR', pt_BR = 'pt-BR',
tr = 'tr',
uk = 'uk', uk = 'uk',
ca = 'ca',
zh_CN = 'zh-CN', zh_CN = 'zh-CN',
zh_TW = 'zh-TW', zh_TW = 'zh-TW',
it = 'it',
tr = 'tr',
} }
interface AppLanguageConfig { interface AppLanguageConfig {
@ -31,22 +31,22 @@ interface AppLanguageConfig {
export const APP_LANGUAGES: AppLanguageConfig[] = [ export const APP_LANGUAGES: AppLanguageConfig[] = [
{code2: AppLanguage.en, name: 'English'}, {code2: AppLanguage.en, name: 'English'},
{code2: AppLanguage.ca, name: 'Català Catalan'},
{code2: AppLanguage.de, name: 'Deutsch German'}, {code2: AppLanguage.de, name: 'Deutsch German'},
{code2: AppLanguage.es, name: 'Español Spanish'}, {code2: AppLanguage.es, name: 'Español Spanish'},
{code2: AppLanguage.fi, name: 'Suomi Finnish'}, {code2: AppLanguage.fi, name: 'Suomi Finnish'},
{code2: AppLanguage.fr, name: 'Français French'}, {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.hi, name: 'हिंदी Hindi'},
{code2: AppLanguage.id, name: 'Bahasa Indonesia Indonesian'}, {code2: AppLanguage.id, name: 'Bahasa Indonesia Indonesian'},
{code2: AppLanguage.it, name: 'Italiano Italian'},
{code2: AppLanguage.ja, name: '日本語 Japanese'}, {code2: AppLanguage.ja, name: '日本語 Japanese'},
{code2: AppLanguage.ko, name: '한국어 Korean'}, {code2: AppLanguage.ko, name: '한국어 Korean'},
{code2: AppLanguage.pt_BR, name: 'Português (BR) Portuguese (BR)'}, {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.uk, name: 'Українська Ukrainian'},
{code2: AppLanguage.ca, name: 'Català Catalan'}, {code2: AppLanguage.zh_CN, name: '简体中文(中国)– Chinese (Simplified)'},
{code2: AppLanguage.zh_CN, name: '简体中文(中国) Chinese (Simplified)'}, {code2: AppLanguage.zh_TW, name: '繁體中文(臺灣)– Chinese (Traditional)'},
{code2: AppLanguage.zh_TW, name: '繁體中文(臺灣) Chinese (Traditional)'},
{code2: AppLanguage.it, name: 'Italiano - Italian'},
{code2: AppLanguage.tr, name: 'Türkçe - Turkish'},
] ]
export const LANGUAGES: Language[] = [ export const LANGUAGES: Language[] = [