Skip to content

Commit db05ce2

Browse files
benallengfuturepaul
authored andcommitted
feat: add translation section to README
1 parent 1f996cb commit db05ce2

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,57 @@ openssl base64 < <my-release-key.keystore> | tr -d '\n' | tee some_signing_key.j
118118
- `SIGNING_KEY` <- the data from `<my-release-key.keystore>`
119119
3. Change the `versionCode` and `versionName` on `app/build.gradle`
120120
4. Commit and push.
121+
122+
## Translating
123+
124+
### Testing language keys
125+
126+
To check what keys are missing from your desired language:
127+
128+
```
129+
just i18n $lang
130+
```
131+
132+
### Adding new languages or keys
133+
134+
1. In `src/i18n/` locate your desired language folder or create one if one does not exist
135+
- When creating a new language dir ensure it follows the ISO 639 2-letter standard
136+
137+
2. In this folder create a file called `translations.ts`, this is where the translation keys for your desired language will be located
138+
139+
3. Populate your translation file with a translation object where all of the keys will be located
140+
141+
If you want to add Japanese you will create a file `/src/i18n/jp/translations.ts` and populate it with keys like so:
142+
```
143+
export default {
144+
Common: {
145+
continue: "続ける",
146+
...
147+
}
148+
}
149+
```
150+
(You should compare your translations against the English language as all other languages are not the master and are likely deprecated)
151+
152+
4. Add your new translation file to the `/src/i18n/config.ts` so you can begin to see them in the app
153+
154+
```
155+
import fa from "~/i18n/jp/translations.ts"
156+
157+
export const resources: {
158+
...
159+
jp: {
160+
translations: jp
161+
}
162+
}
163+
```
164+
165+
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
166+
```
167+
export const LANGUAGE_OPTIONS: Language[] = [
168+
{
169+
value: "日本語",
170+
shortName: "jp"
171+
},
172+
```
173+
174+
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 commit comments

Comments
 (0)