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 authored and futurepaul committed Feb 22, 2024
1 parent 1f996cb commit db05ce2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,57 @@ 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

### Testing language keys

To check what keys are missing from your desired language:

```
just i18n $lang
```

### 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 Japanese you will create a file `/src/i18n/jp/translations.ts` and populate it with keys like so:
```
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/jp/translations.ts"
export const resources: {
...
jp: {
translations: jp
}
}
```

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 selected automatically
```
export const LANGUAGE_OPTIONS: Language[] = [
{
value: "日本語",
shortName: "jp"
},
```

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!

0 comments on commit db05ce2

Please sign in to comment.