From 8d9af5e3a901a0e972da877cdb7dcb389dc59599 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 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/README.md b/README.md index bfabb343..6cf9b52f 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,58 @@ 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 + +### 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 +```