diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index 8dc84276..c31bd0b4 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -16,18 +16,29 @@ export const i18n = new I18n({ 'en-US': en }) */ i18n.translations = { en, "en-US": en, - sk, 'sk_SK': sk + sk } // important! i18n.defaultLocale = 'en' i18n.enableFallback = true; -i18n.locale = Platform.OS === 'ios' +// i wanted to use Intl.Locale to parse this and get the base language +// however, seems like Intl.Locale is either not implemented in hermes or not workiking for this version +// also, react native provides locales in the en_US format, whereas js expect them in en-US format +// this is smaller than a full intl polyfill and does what we need + +const fullLocaleRN: string = (Platform.OS === 'ios' ? NativeModules.SettingsManager.settings.AppleLocale : NativeModules.I18nManager.localeIdentifier +).toString().replaceAll('_', '-') + +const localeJSFormat = fullLocaleRN.includes("-") + ? fullLocaleRN.split("-")[0] + : fullLocaleRN.slice(0, 2) + +i18n.locale = localeJSFormat -console.log(i18n.locale) /** * Builds up valid keypaths for translations. diff --git a/src/i18n_messages/sk.json b/src/i18n_messages/sk.json index 74b75e59..1893775b 100644 --- a/src/i18n_messages/sk.json +++ b/src/i18n_messages/sk.json @@ -16,6 +16,9 @@ }, "payCommon": { "amountToPayLabel": "Suma na zaplatenie", + "receive": "Prijať", + "receiveEcash": "Prijať ecash", + "receiveOffline": "Prijať offline", "send": "Poslať" }, "sendScreen": {