From 56e4d2c6f1ada4526599ccddd45a81697b0cc163 Mon Sep 17 00:00:00 2001 From: merrime-n <100111649+merrime-n@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:12:49 +0330 Subject: [PATCH] docs: add file paths to the new language guide (#7454) * improve the comprehensiblity of translation contribution docs * Update CONTRIBUTING.md to fix the code blocks appeareance --- CONTRIBUTING.md | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1ff77f449f..c401c3c2cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -186,41 +186,39 @@ Adding a new language involves several steps to ensure it integrates seamlessly 1. **Update type definitions** Add the new language to the TLanguage type in the language definitions file: - ```typescript - // types/language.ts - export type TLanguage = "en" | "fr" | "your-lang"; - ``` +```ts + // packages/i18n/src/types/language.ts + export type TLanguage = "en" | "fr" | "your-lang"; +``` -2. **Add language configuration** +1. **Add language configuration** Include the new language in the list of supported languages: +```ts + // packages/i18n/src/constants/language.ts + export const SUPPORTED_LANGUAGES: ILanguageOption[] = [ + { label: "English", value: "en" }, + { label: "Your Language", value: "your-lang" } + ]; +``` - ```typescript - // constants/language.ts - export const SUPPORTED_LANGUAGES: ILanguageOption[] = [ - { label: "English", value: "en" }, - { label: "Your Language", value: "your-lang" } - ]; - ``` - -3. **Create translation files** +2. **Create translation files** 1. Create a new folder for your language under locales (e.g., `locales/your-lang/`). 2. Add a `translations.json` file inside the folder. 3. Copy the structure from an existing translation file and translate all keys. -4. **Update import logic** +3. **Update import logic** Modify the language import logic to include your new language: - - ```typescript - private importLanguageFile(language: TLanguage): Promise { - switch (language) { - case "your-lang": - return import("../locales/your-lang/translations.json"); - // ... - } - } - ``` +```ts + private importLanguageFile(language: TLanguage): Promise { + switch (language) { + case "your-lang": + return import("../locales/your-lang/translations.json"); + // ... + } + } +``` ### Quality checklist