Skip to content

Commit

Permalink
feat: add translation section to README
Browse files Browse the repository at this point in the history
  • Loading branch information
benalleng committed Feb 22, 2024
1 parent bb8c6e6 commit 8d9af5e
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,58 @@ openssl base64 < <my-release-key.keystore> | tr -d '\n' | tee some_signing_key.j
- `SIGNING_KEY` <- the data from `<my-release-key.keystore>`
3. Change the `versionCode` and `versionName` on `app/build.gradle`
4. Commit and push.

## Translating

### Adding new languages or keys

1. In `src/i18n/` locate your desired language folder or create one if one does not exist
- When creating a new language dir ensure it follows the ISO 639 2-letter standard

2. In this folder create a file called `translations.ts`, this is where the translation keys for your desired language will be located

3. Populate your translation file with a translation object where all of the keys will be located

If you want to add Persian/Farsi you will create a file `/src/i18n/fa/translations.ts` and poulate it with keys like so:
```
/src/i18n/fa/translations.ts
export default {
Common: {
continue: "ادامه"
}...
}
```
(You should compare your translations against the English language as all other languages are not the master and are likely deprecated)

4. Add your new translation file to the `/src/i18n/config.ts` so you can begin to see them in the app

```
import fa from "~/i18n/fa/translations.ts"
export const resources: {
...
fa: {
translations: fa
}
}
```

5. Add your language to the `Language` object in `/src/utils/languages.ts`. This will allow you to select the language via the language selector in the UI. If your desired language is set as your primary language in your browser it will be selectedd automatically
```
export const LANGUAGE_OPTIONS: Language[] = [
{
value: "فارسی",
shortName: "fa"
},
```

6. That's it! You should now be able to see your translation keys populating the app in your desired language. When youre ready go ahead and open a PR to have you language merged for others!

### Testing language keys

To check what keys are missing from your desired language:

```
just i18n $lang
```

0 comments on commit 8d9af5e

Please sign in to comment.