Skip to content

Commit

Permalink
Alphabetise languages by language code (#3350)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
surfdude29 authored Apr 4, 2024
1 parent 51e939e commit 8b3017b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions lingui.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
module.exports = {
locales: [
'en',
'ca',
'de',
'es',
'fi',
'fr',
'ga',
'hi',
'id',
'it',
'ja',
'ko',
'pt-BR',
'tr',
'uk',
'ca',
'zh-CN',
'zh-TW',
'it',
'tr',
],
catalogs: [
{
Expand Down
12 changes: 6 additions & 6 deletions src/locale/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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
}
Expand Down
24 changes: 12 additions & 12 deletions src/locale/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/locale/i18n.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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: {
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/locale/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ interface Language {

export enum AppLanguage {
en = 'en',
ca = 'ca',
de = 'de',
es = 'es',
fi = 'fi',
fr = 'fr',
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 {
Expand All @@ -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[] = [
Expand Down

0 comments on commit 8b3017b

Please sign in to comment.