Override legacy language codes for indonesian, hebrew, and yiddish (#4461)
* Manually override incorrect 'in' to 'id' lang code * Fix additional legacy language code issueszio/stable
parent
620ab88713
commit
59f49bef68
|
@ -116,7 +116,7 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
|
|||
const langs = appLanguage.split(',').filter(Boolean)
|
||||
|
||||
for (const lang of langs) {
|
||||
switch (lang) {
|
||||
switch (fixLegacyLanguageCode(lang)) {
|
||||
case 'en':
|
||||
return AppLanguage.en
|
||||
case 'ca':
|
||||
|
@ -157,3 +157,20 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
|
|||
}
|
||||
return AppLanguage.en
|
||||
}
|
||||
|
||||
export function fixLegacyLanguageCode(code: string | null): string | null {
|
||||
// handle some legacy code conversions, see https://xml.coverpages.org/iso639a.html
|
||||
if (code === 'in') {
|
||||
// indonesian
|
||||
return 'id'
|
||||
}
|
||||
if (code === 'iw') {
|
||||
// hebrew
|
||||
return 'he'
|
||||
}
|
||||
if (code === 'ji') {
|
||||
// yiddish
|
||||
return 'yi'
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {Platform} from 'react-native'
|
|||
import {isReducedMotion} from 'react-native-reanimated'
|
||||
import {getLocales} from 'expo-localization'
|
||||
|
||||
import {fixLegacyLanguageCode} from '#/locale/helpers'
|
||||
import {dedupArray} from 'lib/functions'
|
||||
|
||||
export const isIOS = Platform.OS === 'ios'
|
||||
|
@ -17,7 +18,7 @@ export const isMobileWeb =
|
|||
|
||||
export const deviceLocales = dedupArray(
|
||||
getLocales?.()
|
||||
.map?.(locale => locale.languageCode)
|
||||
.map?.(locale => fixLegacyLanguageCode(locale.languageCode))
|
||||
.filter(code => typeof code === 'string'),
|
||||
) as string[]
|
||||
|
||||
|
|
Loading…
Reference in New Issue