Skip to content

Commit

Permalink
localization is based on expo-localization
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzitelli committed Jan 8, 2022
1 parent 3b49fdf commit 7c2d349
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
18 changes: 6 additions & 12 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PODS:
- ExpoModulesCore
- Expo (44.0.4):
- ExpoModulesCore
- ExpoLocalization (12.0.0):
- ExpoModulesCore
- ExpoModulesCore (0.6.4):
- React-Core
- ReactCommon/turbomodule/core
Expand Down Expand Up @@ -398,12 +400,8 @@ PODS:
- React
- RNCAsyncStorage (1.15.14):
- React-Core
- RNDeviceInfo (8.4.8):
- React-Core
- RNGestureHandler (2.1.0):
- React-Core
- RNLocalize (2.1.7):
- React-Core
- RNReanimated (2.2.4):
- DoubleConversion
- FBLazyVector
Expand Down Expand Up @@ -449,6 +447,7 @@ DEPENDENCIES:
- EXFont (from `../node_modules/expo-font/ios`)
- EXKeepAwake (from `../node_modules/expo-keep-awake/ios`)
- Expo (from `../node_modules/expo/ios`)
- ExpoLocalization (from `../node_modules/expo-localization/ios`)
- ExpoModulesCore (from `../node_modules/expo-modules-core/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
Expand Down Expand Up @@ -509,9 +508,7 @@ DEPENDENCIES:
- ReactNativeNavigation (from `../node_modules/react-native-navigation`)
- ReactNativeUiLib (from `../node_modules/react-native-ui-lib/lib`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNLocalize (from `../node_modules/react-native-localize`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
Expand Down Expand Up @@ -556,6 +553,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-keep-awake/ios"
Expo:
:path: "../node_modules/expo/ios"
ExpoLocalization:
:path: "../node_modules/expo-localization/ios"
ExpoModulesCore:
:path: "../node_modules/expo-modules-core/ios"
FBLazyVector:
Expand Down Expand Up @@ -626,12 +625,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-ui-lib/lib"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNLocalize:
:path: "../node_modules/react-native-localize"
RNReanimated:
:path: "../node_modules/react-native-reanimated"
RNVectorIcons:
Expand All @@ -650,6 +645,7 @@ SPEC CHECKSUMS:
EXFont: 1fb13af43dc517c01c0ff21a6e32f9f9bf2ea602
EXKeepAwake: b571c2ad8323b2fced6e907766e2549f75119471
Expo: d9b8b5e49c200471fc473a652a84fe30dee73027
ExpoLocalization: 83582a967db52987a8479490b056d5eb9fd70552
ExpoModulesCore: 64abda7af7cf659d2fa092934e29c6f4ea7e849f
FBLazyVector: e5569e42a1c79ca00521846c223173a57aca1fe1
FBReactNativeSpec: fe08c1cd7e2e205718d77ad14b34957cce949b58
Expand Down Expand Up @@ -701,9 +697,7 @@ SPEC CHECKSUMS:
ReactNativeNavigation: 0a768a3eb149e808ca28e12ffbca9b3efecb4ddf
ReactNativeUiLib: cde7263a7d308b60161cd286f95c9433e79f2f7d
RNCAsyncStorage: ea6b5c280997b2b32a587793163b1f10e580c4f7
RNDeviceInfo: 0400a6d0c94186d1120c3cbd97b23abc022187a9
RNGestureHandler: e5c7cab5f214503dcefd6b2b0cefb050e1f51c4a
RNLocalize: f567ea0e35116a641cdffe6683b0d212d568f32a
RNReanimated: 65583befd5706cc9c86ae9a081786181ced37b93
RNVectorIcons: 4143ba35feebab8fdbe6bc43d1e776b393d47ac8
Yoga: e7dc4e71caba6472ff48ad7d234389b91dadc280
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@react-native-community/blur": "^3.6.0",
"date-fns": "^2.28.0",
"expo": "^44.0.4",
"expo-localization": "^12.0.0",
"formik": "^2.2.9",
"i18n-js": "^3.8.0",
"lodash": "^4.17.21",
Expand Down
24 changes: 10 additions & 14 deletions src/services/translate/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getLocales} from 'react-native-localize';
import * as Localization from 'expo-localization';
import i18n from 'i18n-js';

import {ru, en} from './translations';
Expand All @@ -18,19 +18,15 @@ export class TranslateService implements IService {
do = i18n.t;

setup = (): void => {
const locales = getLocales();

if (locales.length > 0) {
const {ui} = stores;
const lng = locales[0].languageCode;

i18n.translations = {en, ru};
i18n.fallbacks = true;
if (ui.isSystemLanguage) {
i18n.locale = lng;
} else {
i18n.locale = ui.language;
}
const {ui} = stores;
const lng = Localization.locale;

i18n.translations = {en, ru};
i18n.fallbacks = true;
if (ui.isSystemLanguage) {
i18n.locale = lng;
} else {
i18n.locale = ui.language;
}
};
}
22 changes: 12 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5407,6 +5407,13 @@ expo-keep-awake@~10.0.1:
resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-10.0.1.tgz#9f1176216c41eee20843c8232acfdca2bc32d334"
integrity sha512-kcBtoDGkm3RRe6BpKDvR7gof/ErajEia38u92pRvNRctdh+p8AFO7GQuiipyg3iMfhcCFVTCIV7h3tuA0g/yDw==

expo-localization@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/expo-localization/-/expo-localization-12.0.0.tgz#c7ed86d32a99eece45541b3f53f287eec4865d25"
integrity sha512-CXHRyLqpO+PlX0AQEw0kGYRO9NCPu+tmtx/b39gyC895/UP0Gczn6UoiOpuujqXx6n16NNLnu9UJ+P2UcRquVA==
dependencies:
rtl-detect "^1.0.2"

[email protected]:
version "0.5.5"
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-0.5.5.tgz#6bcc42072dcbdfca79d207b7f549f1fdb54a2b74"
Expand Down Expand Up @@ -9078,11 +9085,6 @@ [email protected]:
react-native-slider "^0.11.0"
tinycolor2 "^1.4.1"

react-native-device-info@^8.4.8:
version "8.4.8"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-8.4.8.tgz#fc92ae423e47db6cfbf30c30012e09cee63727fa"
integrity sha512-92676ZWHZHsPM/EW1ulgb2MuVfjYfMWRTWMbLcrCsipkcMaZ9Traz5mpsnCS7KZpsOksnvUinzDIjsct2XGc6Q==

react-native-gesture-handler@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.1.0.tgz#be7a83a7bd340a2316551a4d30d7abf06b46c1da"
Expand All @@ -9094,11 +9096,6 @@ react-native-gesture-handler@^2.1.0:
lodash "^4.17.21"
prop-types "^15.7.2"

react-native-localize@^2.1.7:
version "2.1.7"
resolved "https://registry.yarnpkg.com/react-native-localize/-/react-native-localize-2.1.7.tgz#f1dda0c6fd58ab06b5b119cb4a507ab8800b9823"
integrity sha512-phimOUtDLiqY2ba7Rjk9KpuaVSo7iGMNnwr7rjBVqlhmtTF3ShQ1FPFPxOyUrzDU9jLtj1xMi7MXWYuiVg660Q==

react-native-mmkv@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/react-native-mmkv/-/react-native-mmkv-1.6.2.tgz#2945203a3a8278f5c2cb935bf9bb789bbe5fa91e"
Expand Down Expand Up @@ -9610,6 +9607,11 @@ rsvp@^4.8.4:
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
integrity sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==

rtl-detect@^1.0.2:
version "1.0.4"
resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.4.tgz#40ae0ea7302a150b96bc75af7d749607392ecac6"
integrity sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==

run-async@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455"
Expand Down

0 comments on commit 7c2d349

Please sign in to comment.