INNER CODE UNIT · TypeScript
getDeviceLocale
RushB-fr/freekiosk · src/i18n/index.ts:11
function getDeviceLocale(): string {
const locale =
Platform.OS === 'ios'
? NativeModules.SettingsManager?.settings?.AppleLocale ||
NativeModules.SettingsManager?.settings?.AppleLanguages?.[0]
: NativeModules.I18nManager?.localeIdentifier;
return typeof locale === 'string' ? locale : 'en';
}
export function resolveSupportedLanguage(code: string | null | undefined): SupportedLanguage {
if (code && (SUPPORTED_LANGUAGES as readonly string[]).includes(code)) {
return code as SupportedLanguage;
}
return 'en';
}
i18next.use(initReactI18next).init({
compatibilityJSON: 'v4',