Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

change(i18n): Migrate to react-native-localize #165

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions boilerplate/app/i18n/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import RNLanguages from "react-native-languages"
import * as RNLocalize from "react-native-localize"
import i18n from "i18n-js"

const en = require("./en")
const ja = require("./ja")

i18n.locale = RNLanguages.language
i18n.fallbacks = true
i18n.translations = { en, ja }

const fallback = { languageTag: "en", isRTL: false }
const { languageTag } = RNLocalize.findBestAvailableLanguage(Object.keys(i18n.translations)) || fallback
i18n.locale = languageTag
2 changes: 1 addition & 1 deletion boilerplate/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mobx-react": "5.2.8",
"mobx-state-tree": "2.0.5",
"ramda": "0.25.0",
"react-native-languages": "^3.0.0",
"react-native-localize": "^1.0.0",
"i18n-js": "^3.0.11",
"react-native-keychain": "3.0.0",
"react-native-splash-screen": "3.1.1",
Expand Down
5 changes: 0 additions & 5 deletions boilerplate/test/mock-react-native-languages.ts

This file was deleted.

8 changes: 8 additions & 0 deletions boilerplate/test/mock-react-native-localize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
jest.mock("react-native-localize", () => {
return {
findBestAvailableLanguage: ([language = "en"]) => ({
languageTag: language,
isRTL: false,
}),
}
})
2 changes: 1 addition & 1 deletion boilerplate/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "react-native"
import "./mock-i18n"
import "./mock-reactotron"
import "./mock-textinput"
import "./mock-react-native-languages"
import "./mock-react-native-localize"

declare global {
var __TEST__
Expand Down