Skip to content

Commit

Permalink
fix(translate): add more languages
Browse files Browse the repository at this point in the history
  • Loading branch information
tobua committed Dec 10, 2023
1 parent cf4f00c commit faf69fc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ const settingsText = translate('title')
const Heading = <Text style={{ fontSize: 32 }}>title</Text>
```

For compatibility reasons the following `package.json` entries are required. The first entry adds package exports support to metro while the second downgrades [`chalk`](https://npmjs.com/chalk) to a version that does not yet require package imports.

```json
{
"metro": {
"resolver": {
"unstable_enablePackageExports": true
}
ES Module exports are still an experimental feature in React Native's Metro bundler. Since this plugin requires them you have to turn them in your `metro.config.js` with:

```js
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')

const config = {
resolver: {
unstable_enablePackageExports: true,
},
"overrides": {
"chalk": "^4.1.2"
}
}

module.exports = mergeConfig(getDefaultConfig(__dirname), config)
```
10 changes: 10 additions & 0 deletions helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ export const readableLanguage: Record<Languages, string> = {
[Language.de]: 'Deutsch',
[Language.fr]: 'Français',
[Language.it]: 'Italiano',
[Language.hi]: 'हिन्दी',
[Language.ja]: '日本語',
[Language.ko]: '한국어',
[Language.pt]: 'Português',
[Language.ru]: 'русский язык',
[Language.ar]: 'اَلْعَرَبِيَّةُ',
[Language.bn]: 'বাংলা',
[Language.vi]: 'Tiếng Việt',
[Language.tr]: 'Türkçe',
[Language.fa]: 'فارسی',
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
}
},
"dependencies": {
"logua": "^3.0.2",
"logua": "^3.0.3",
"minimist": "^1.2.8"
},
"devDependencies": {
"@happy-dom/global-registrator": "^12.10.3",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.42",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"bun-types": "^1.0.15",
"bun-types": "^1.0.16",
"happy-dom": "^12.10.3",
"openai": "^4.20.1",
"padua": "^2.0.7",
Expand Down
11 changes: 11 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ export type Sheet<T extends string | number | symbol = string> = {
export type Sheets<T extends Sheet> = { [key in Language]?: Sheet<keyof T> }
export type Replacement = string | number

// https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
export enum Language {
en = 'en',
es = 'es',
zh = 'zh',
de = 'de',
fr = 'fr',
it = 'it',
hi = 'hi',
ja = 'ja',
ko = 'ko',
pt = 'pt',
ru = 'ru',
ar = 'ar',
bn = 'bn',
vi = 'vi',
tr = 'tr',
fa = 'fa',
}

export type Languages = keyof typeof Language
Expand Down

0 comments on commit faf69fc

Please sign in to comment.