From db05ce202f03ac592036104e0e8185bed14d119f Mon Sep 17 00:00:00 2001 From: benalleng Date: Thu, 22 Feb 2024 16:02:03 -0500 Subject: [PATCH] feat: add translation section to README --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index bfabb343..5afa7a3f 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,57 @@ openssl base64 < | tr -d '\n' | tee some_signing_key.j - `SIGNING_KEY` <- the data from `` 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!