Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically load translations #27

Merged
merged 7 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 3 additions & 10 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import { useFonts } from "expo-font";
import { EvaIconsPack } from "@ui-kitten/eva-icons";
import * as SplashScreen from "expo-splash-screen";
import { decode, encode } from "base-64";
import translations from './i18n';

import translationEN from "./i18n/en.json";
import translationDE from "./i18n/de.json";
import translationLT from "./i18n/lt.json";
if (!global.btoa) {
global.btoa = encode;
}
Expand All @@ -37,17 +35,12 @@ SplashScreen.preventAutoHideAsync();

const Stack = createNativeStackNavigator();

const resources = {
en: { translation: translationEN },
de: { translation: translationDE },
lt: { translation: translationLT },
};

i18n.use(initReactI18next).init({
resources,
resources: translations,
lng: getLocales()[0].languageCode,
fallbackLng: "en",
});
console.log(getLocales());
Maschga marked this conversation as resolved.
Show resolved Hide resolved

function AppNavigator() {
const { serverUrl } = useAppContext();
Expand Down
23 changes: 23 additions & 0 deletions i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Resource } from "i18next";

import de from "./de.json";
import en from "./en.json";
import fi from "./fi.json";
import fr from "./fr.json";
import lb from "./lb.json";
import lt from "./lt.json";
import pl from "./pl.json";
import pt from "./pt.json";

const translations: Resource = {
de: { translation: de },
en: { translation: en },
fi: { translation: fi },
fr: { translation: fr },
lb: { translation: lb },
lt: { translation: lt },
pl: { translation: pl },
pt: { translation: pt }
};

export default translations;
190 changes: 182 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"ios": "expo run:ios",
"web": "expo start --web",
"lint": "tsc --noEmit && eslint .",
"format": "prettier --write ."
"format": "prettier --write .",
"translations": "ts-node ./scripts/load-translations.ts"
},
"dependencies": {
"@eva-design/eva": "^2.2.0",
Expand Down Expand Up @@ -53,12 +54,14 @@
"@babel/core": "^7.20.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"eslint": "^9.9.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-native": "^4.1.0",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"ts-node": "^10.9.2"
},
"private": true
}
Loading
Loading