Created
October 12, 2019 00:52
-
-
Save HerbertLim/4a9756e50dbdfd5328a13c1ddb2b6dfc to your computer and use it in GitHub Desktop.
Modified version expo-localization's Localization.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// caused error when running with iOS Simulator | |
// because iOS Simulator does not provide locale and timezone | |
import ExpoLocalization from './ExpoLocalization'; | |
// Web, Android, and some iOS values use `-`. This will convert the iOS values that use `_` | |
// https://github.com/expo/expo/blob/21ae94bae2e8369992050c433a00699d425b35bd/packages/expo/src/Localization.ts#L112-L114 | |
const parseLocale = (locale) => locale.replace('_', '-'); <-- Original | |
const parseLocale = (locale) => {if (!locale) return null; return locale.replace('_', '-')}; <-- Modified | |
export const locale = parseLocale(ExpoLocalization.locale); | |
export const locales = ExpoLocalization.locales.map(parseLocale); <-- Original | |
export const locales = ExpoLocalization.locales ? ExpoLocalization.locales.map(parseLocale) : []; <-- Modified | |
export const timezone = ExpoLocalization.timezone; | |
export const isoCurrencyCodes = ExpoLocalization.isoCurrencyCodes; | |
export const region = ExpoLocalization.region; // iOS, Web | |
export const isRTL = ExpoLocalization.isRTL; | |
export async function getLocalizationAsync() { | |
const { locale, locales, ...localization } = await ExpoLocalization.getLocalizationAsync(); | |
return { | |
locale: parseLocale(locale), | |
locales: ExpoLocalization.locales.map(parseLocale), | |
...localization, | |
}; | |
} | |
//# sourceMappingURL=Localization.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment