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
This commit is contained in:
merrime-n
2025-07-24 12:12:49 +03:30
committed by GitHub
parent d7e58a60fa
commit 56e4d2c6f1

View File

@@ -186,33 +186,31 @@ Adding a new language involves several steps to ensure it integrates seamlessly
1. **Update type definitions** 1. **Update type definitions**
Add the new language to the TLanguage type in the language definitions file: Add the new language to the TLanguage type in the language definitions file:
```typescript ```ts
// types/language.ts // packages/i18n/src/types/language.ts
export type TLanguage = "en" | "fr" | "your-lang"; 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: Include the new language in the list of supported languages:
```ts
```typescript // packages/i18n/src/constants/language.ts
// constants/language.ts
export const SUPPORTED_LANGUAGES: ILanguageOption[] = [ export const SUPPORTED_LANGUAGES: ILanguageOption[] = [
{ label: "English", value: "en" }, { label: "English", value: "en" },
{ label: "Your Language", value: "your-lang" } { 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/`). 1. Create a new folder for your language under locales (e.g., `locales/your-lang/`).
2. Add a `translations.json` file inside the folder. 2. Add a `translations.json` file inside the folder.
3. Copy the structure from an existing translation file and translate all keys. 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: Modify the language import logic to include your new language:
```ts
```typescript
private importLanguageFile(language: TLanguage): Promise<any> { private importLanguageFile(language: TLanguage): Promise<any> {
switch (language) { switch (language) {
case "your-lang": case "your-lang":