Merge branch 'main' into main
This commit is contained in:
@@ -11,4 +11,5 @@ test('sanitizeAppLanguageSetting', () => {
|
||||
expect(sanitizeAppLanguageSetting('foo')).toBe(AppLanguage.en)
|
||||
expect(sanitizeAppLanguageSetting('en,foo')).toBe(AppLanguage.en)
|
||||
expect(sanitizeAppLanguageSetting('foo,en')).toBe(AppLanguage.en)
|
||||
expect(sanitizeAppLanguageSetting('vi')).toBe(AppLanguage.vi)
|
||||
})
|
||||
|
||||
@@ -13,6 +13,12 @@ type LocalWithLanguageCode = Locale & {
|
||||
*
|
||||
* {@link https://github.com/bluesky-social/social-app/pull/4461}
|
||||
* {@link https://xml.coverpages.org/iso639a.html}
|
||||
*
|
||||
* Convert Chinese language tags for Native.
|
||||
*
|
||||
* {@link https://datatracker.ietf.org/doc/html/rfc5646#appendix-A}
|
||||
* {@link https://developer.apple.com/documentation/packagedescription/languagetag}
|
||||
* {@link https://gist.github.com/amake/0ac7724681ac1c178c6f95a5b09f03ce#new-locales-vs-old-locales-chinese}
|
||||
*/
|
||||
export function getLocales() {
|
||||
const locales = defaultGetLocales?.() ?? []
|
||||
@@ -32,10 +38,25 @@ export function getLocales() {
|
||||
// yiddish
|
||||
locale.languageCode = 'yi'
|
||||
}
|
||||
|
||||
// @ts-ignore checked above
|
||||
output.push(locale)
|
||||
}
|
||||
|
||||
if (typeof locale.languageTag === 'string') {
|
||||
if (locale.languageTag.startsWith('zh-Hans')) {
|
||||
// Simplified Chinese to zh-CN
|
||||
locale.languageTag = 'zh-CN'
|
||||
}
|
||||
if (locale.languageTag.startsWith('zh-Hant')) {
|
||||
// Traditional Chinese to zh-TW
|
||||
locale.languageTag = 'zh-TW'
|
||||
}
|
||||
if (locale.languageTag.startsWith('yue')) {
|
||||
// Cantonese (Yue) to zh-HK
|
||||
locale.languageTag = 'zh-HK'
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore checked above
|
||||
output.push(locale)
|
||||
}
|
||||
|
||||
return output
|
||||
|
||||
@@ -101,7 +101,7 @@ export function getTranslatorLink(text: string, lang: string): string {
|
||||
/**
|
||||
* Returns a valid `appLanguage` value from an arbitrary string.
|
||||
*
|
||||
* Contenxt: post-refactor, we populated some user's `appLanguage` setting with
|
||||
* Context: post-refactor, we populated some user's `appLanguage` setting with
|
||||
* `postLanguage`, which can be a comma-separated list of values. This breaks
|
||||
* `appLanguage` handling in the app, so we introduced this util to parse out a
|
||||
* valid `appLanguage` from the pre-populated `postLanguage` values.
|
||||
@@ -133,6 +133,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
|
||||
return AppLanguage.fr
|
||||
case 'ga':
|
||||
return AppLanguage.ga
|
||||
case 'gl':
|
||||
return AppLanguage.gl
|
||||
case 'hi':
|
||||
return AppLanguage.hi
|
||||
case 'hu':
|
||||
@@ -147,6 +149,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
|
||||
return AppLanguage.ko
|
||||
case 'nl':
|
||||
return AppLanguage.nl
|
||||
case 'pl':
|
||||
return AppLanguage.pl
|
||||
case 'pt-BR':
|
||||
return AppLanguage.pt_BR
|
||||
case 'ru':
|
||||
@@ -157,6 +161,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
|
||||
return AppLanguage.tr
|
||||
case 'uk':
|
||||
return AppLanguage.uk
|
||||
case 'vi':
|
||||
return AppLanguage.vi
|
||||
case 'zh-CN':
|
||||
return AppLanguage.zh_CN
|
||||
case 'zh-HK':
|
||||
|
||||
+27
-1
@@ -19,6 +19,7 @@ import {messages as messagesEs} from '#/locale/locales/es/messages'
|
||||
import {messages as messagesFi} from '#/locale/locales/fi/messages'
|
||||
import {messages as messagesFr} from '#/locale/locales/fr/messages'
|
||||
import {messages as messagesGa} from '#/locale/locales/ga/messages'
|
||||
import {messages as messagesGl} from '#/locale/locales/gl/messages'
|
||||
import {messages as messagesHi} from '#/locale/locales/hi/messages'
|
||||
import {messages as messagesHu} from '#/locale/locales/hu/messages'
|
||||
import {messages as messagesId} from '#/locale/locales/id/messages'
|
||||
@@ -26,11 +27,13 @@ import {messages as messagesIt} from '#/locale/locales/it/messages'
|
||||
import {messages as messagesJa} from '#/locale/locales/ja/messages'
|
||||
import {messages as messagesKo} from '#/locale/locales/ko/messages'
|
||||
import {messages as messagesNl} from '#/locale/locales/nl/messages'
|
||||
import {messages as messagesPl} from '#/locale/locales/pl/messages'
|
||||
import {messages as messagesPt_BR} from '#/locale/locales/pt-BR/messages'
|
||||
import {messages as messagesRu} from '#/locale/locales/ru/messages'
|
||||
import {messages as messagesTh} from '#/locale/locales/th/messages'
|
||||
import {messages as messagesTr} from '#/locale/locales/tr/messages'
|
||||
import {messages as messagesUk} from '#/locale/locales/uk/messages'
|
||||
import {messages as messagesVi} from '#/locale/locales/vi/messages'
|
||||
import {messages as messagesZh_CN} from '#/locale/locales/zh-CN/messages'
|
||||
import {messages as messagesZh_HK} from '#/locale/locales/zh-HK/messages'
|
||||
import {messages as messagesZh_TW} from '#/locale/locales/zh-TW/messages'
|
||||
@@ -97,6 +100,14 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
])
|
||||
break
|
||||
}
|
||||
case AppLanguage.gl: {
|
||||
i18n.loadAndActivate({locale, messages: messagesGl})
|
||||
await Promise.all([
|
||||
import('@formatjs/intl-pluralrules/locale-data/gl'),
|
||||
import('@formatjs/intl-numberformat/locale-data/gl'),
|
||||
])
|
||||
break
|
||||
}
|
||||
case AppLanguage.hi: {
|
||||
i18n.loadAndActivate({locale, messages: messagesHi})
|
||||
await Promise.all([
|
||||
@@ -152,6 +163,13 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
import('@formatjs/intl-numberformat/locale-data/nl'),
|
||||
])
|
||||
break
|
||||
case AppLanguage.pl: {
|
||||
i18n.loadAndActivate({locale, messages: messagesPl})
|
||||
await Promise.all([
|
||||
import('@formatjs/intl-pluralrules/locale-data/pl'),
|
||||
import('@formatjs/intl-numberformat/locale-data/pl'),
|
||||
])
|
||||
break
|
||||
}
|
||||
case AppLanguage.pt_BR: {
|
||||
i18n.loadAndActivate({locale, messages: messagesPt_BR})
|
||||
@@ -193,6 +211,14 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
])
|
||||
break
|
||||
}
|
||||
case AppLanguage.vi: {
|
||||
i18n.loadAndActivate({locale, messages: messagesVi})
|
||||
await Promise.all([
|
||||
import('@formatjs/intl-pluralrules/locale-data/vi'),
|
||||
import('@formatjs/intl-numberformat/locale-data/vi'),
|
||||
])
|
||||
break
|
||||
}
|
||||
case AppLanguage.zh_CN: {
|
||||
i18n.loadAndActivate({locale, messages: messagesZh_CN})
|
||||
await Promise.all([
|
||||
@@ -224,7 +250,7 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function useLocaleLanguage() {
|
||||
export function useLocaleLanguage() {
|
||||
const {appLanguage} = useLanguagePrefs()
|
||||
useEffect(() => {
|
||||
dynamicActivate(sanitizeAppLanguageSetting(appLanguage))
|
||||
|
||||
@@ -40,6 +40,10 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
mod = await import(`./locales/ga/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.gl: {
|
||||
mod = await import(`./locales/gl/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.hi: {
|
||||
mod = await import(`./locales/hi/messages`)
|
||||
break
|
||||
@@ -68,6 +72,10 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
mod = await import(`./locales/nl/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.pl: {
|
||||
mod = await import(`./locales/pl/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.pt_BR: {
|
||||
mod = await import(`./locales/pt-BR/messages`)
|
||||
break
|
||||
@@ -88,6 +96,10 @@ export async function dynamicActivate(locale: AppLanguage) {
|
||||
mod = await import(`./locales/uk/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.vi: {
|
||||
mod = await import(`./locales/vi/messages`)
|
||||
break
|
||||
}
|
||||
case AppLanguage.zh_CN: {
|
||||
mod = await import(`./locales/zh-CN/messages`)
|
||||
break
|
||||
|
||||
@@ -13,6 +13,7 @@ export enum AppLanguage {
|
||||
fi = 'fi',
|
||||
fr = 'fr',
|
||||
ga = 'ga',
|
||||
gl = 'gl',
|
||||
hi = 'hi',
|
||||
hu = 'hu',
|
||||
id = 'id',
|
||||
@@ -20,11 +21,13 @@ export enum AppLanguage {
|
||||
ja = 'ja',
|
||||
ko = 'ko',
|
||||
nl = 'nl',
|
||||
pl = 'pl',
|
||||
pt_BR = 'pt-BR',
|
||||
ru = 'ru',
|
||||
th = 'th',
|
||||
tr = 'tr',
|
||||
uk = 'uk',
|
||||
vi = 'vi',
|
||||
zh_CN = 'zh-CN',
|
||||
zh_HK = 'zh-HK',
|
||||
zh_TW = 'zh-TW',
|
||||
@@ -44,6 +47,7 @@ export const APP_LANGUAGES: AppLanguageConfig[] = [
|
||||
{code2: AppLanguage.fi, name: 'Suomi – Finnish'},
|
||||
{code2: AppLanguage.fr, name: 'Français – French'},
|
||||
{code2: AppLanguage.ga, name: 'Gaeilge – Irish'},
|
||||
{code2: AppLanguage.gl, name: 'Galego - Galician'},
|
||||
{code2: AppLanguage.hi, name: 'हिंदी – Hindi'},
|
||||
{code2: AppLanguage.hu, name: 'magyar – Hungarian'},
|
||||
{code2: AppLanguage.id, name: 'Bahasa Indonesia – Indonesian'},
|
||||
@@ -51,11 +55,13 @@ export const APP_LANGUAGES: AppLanguageConfig[] = [
|
||||
{code2: AppLanguage.ja, name: '日本語 – Japanese'},
|
||||
{code2: AppLanguage.ko, name: '한국어 – Korean'},
|
||||
{code2: AppLanguage.nl, name: 'Nederlands – Dutch'},
|
||||
{code2: AppLanguage.pl, name: 'Polski – Polish'},
|
||||
{code2: AppLanguage.pt_BR, name: 'Português (BR) – Portuguese (BR)'},
|
||||
{code2: AppLanguage.ru, name: 'Русский – Russian'},
|
||||
{code2: AppLanguage.th, name: 'ภาษาไทย – Thai'},
|
||||
{code2: AppLanguage.tr, name: 'Türkçe – Turkish'},
|
||||
{code2: AppLanguage.uk, name: 'Українська – Ukrainian'},
|
||||
{code2: AppLanguage.vi, name: 'Tiếng Việt – Vietnamese'},
|
||||
{code2: AppLanguage.zh_CN, name: '简体中文 – Simplified Chinese'},
|
||||
{code2: AppLanguage.zh_TW, name: '繁體中文 – Traditional Chinese'},
|
||||
{code2: AppLanguage.zh_HK, name: '粵文 – Cantonese'},
|
||||
@@ -469,8 +475,8 @@ export const LANGUAGES: Language[] = [
|
||||
{code3: 'roa', code2: '', name: 'Romance languages'},
|
||||
{code3: 'roh', code2: 'rm', name: 'Romansh'},
|
||||
{code3: 'rom', code2: '', name: 'Romany'},
|
||||
{code3: 'rum', code2: 'ro', name: 'Romanian; Moldavian; Moldovan'},
|
||||
{code3: 'ron', code2: 'ro', name: 'Romanian; Moldavian; Moldovan'},
|
||||
{code3: 'rum', code2: 'ro', name: 'Romanian'},
|
||||
{code3: 'ron', code2: 'ro', name: 'Romanian'},
|
||||
{code3: 'run', code2: 'rn', name: 'Rundi'},
|
||||
{code3: 'rup', code2: '', name: 'Aromanian; Arumanian; Macedo-Romanian'},
|
||||
{code3: 'rus', code2: 'ru', name: 'Russian'},
|
||||
|
||||
+1539
-976
File diff suppressed because it is too large
Load Diff
+1499
-928
File diff suppressed because it is too large
Load Diff
+1498
-891
File diff suppressed because it is too large
Load Diff
+1497
-890
File diff suppressed because it is too large
Load Diff
+1637
-1071
File diff suppressed because it is too large
Load Diff
+1500
-929
File diff suppressed because it is too large
Load Diff
+1628
-1293
File diff suppressed because it is too large
Load Diff
+1811
-2380
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+3051
-3805
File diff suppressed because it is too large
Load Diff
+2744
-1819
File diff suppressed because it is too large
Load Diff
+1502
-931
File diff suppressed because it is too large
Load Diff
+1834
-3221
File diff suppressed because it is too large
Load Diff
+1252
-1145
File diff suppressed because it is too large
Load Diff
+1654
-1516
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1553
-982
File diff suppressed because it is too large
Load Diff
+1501
-930
File diff suppressed because it is too large
Load Diff
+2009
-1307
File diff suppressed because it is too large
Load Diff
+1498
-927
File diff suppressed because it is too large
Load Diff
+1499
-928
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2166
-2048
File diff suppressed because it is too large
Load Diff
+2308
-2190
File diff suppressed because it is too large
Load Diff
+2135
-2017
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user