Skip to content

Commit bc43423

Browse files
authored
🌍 i18n: Add Tibetan and Ukrainian languages to localization (#8819)
* 🌍 i18n: Add Tibetan and Ukrainian languages to localization * feat: Update language selector to include Tibetan and Ukrainian options * feat: Add translation files for Tibetan and Ukrainian languages * chore: Update English translation.json with new language keys * docs: Create localization guide for adding new languages * Update README.md
1 parent 863401b commit bc43423

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

client/src/components/Nav/SettingsTabs/General/General.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export const LangSelector = ({
105105
{ value: 'nl-NL', label: localize('com_nav_lang_dutch') },
106106
{ value: 'id-ID', label: localize('com_nav_lang_indonesia') },
107107
{ value: 'fi-FI', label: localize('com_nav_lang_finnish') },
108+
{ value: 'bo', label: localize('com_nav_lang_tibetan') },
109+
{ value: 'uk-UA', label: localize('com_nav_lang_ukrainian') },
108110
];
109111

110112
return (

client/src/locales/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# LibreChat Localization Guide
2+
3+
This guide explains how to add new languages to LibreChat's localization system.
4+
5+
## Adding a New Language
6+
7+
To add a new language to LibreChat, follow these steps:
8+
9+
### 1. Add the Language to Locize Project
10+
11+
- Navigate to the [LibreChat locize project](https://www.locize.app/cat/62uyy7c9),
12+
- Click the "ADD LANGUAGE" button, typically found within the "..." menu of the "Start to translate" card on the project overview page.
13+
14+
### 2. Update the Language Selector Component
15+
16+
Edit `client/src/components/Nav/SettingsTabs/General/General.tsx` and add your new language option to the `languageOptions` array:
17+
18+
```typescript
19+
{ value: 'language-code', label: localize('com_nav_lang_language_name') },
20+
```
21+
22+
Example:
23+
```typescript
24+
{ value: 'bo', label: localize('com_nav_lang_tibetan') },
25+
{ value: 'uk-UA', label: localize('com_nav_lang_ukrainian') },
26+
```
27+
28+
**Note:** Use the appropriate language code format:
29+
- Use simple codes (e.g., `bo`) for languages without regional variants
30+
- Use region-specific codes (e.g., `uk-UA`) when needed
31+
32+
### 3. Add Localization Keys
33+
34+
In `client/src/locales/en/translation.json`, add the corresponding localization key for your language label:
35+
36+
```json
37+
"com_nav_lang_language_name": "Native Language Name",
38+
```
39+
40+
Example:
41+
```json
42+
"com_nav_lang_tibetan": "བོད་སྐད་",
43+
"com_nav_lang_ukrainian": "Українська",
44+
```
45+
46+
**Best Practice:** Use the native language name as the value.
47+
48+
### 4. Create the Translation File
49+
50+
Create a new directory and translation file:
51+
52+
```bash
53+
mkdir -p client/src/locales/[language-code]
54+
```
55+
56+
Create `client/src/locales/[language-code]/translation.json` with an empty JSON object:
57+
58+
```json
59+
{
60+
}
61+
```
62+
63+
Example:
64+
- `client/src/locales/bo/translation.json`
65+
- `client/src/locales/uk/translation.json`
66+
67+
### 5. Configure i18n
68+
69+
Update `client/src/locales/i18n.ts`:
70+
71+
1. Import the new translation file:
72+
```typescript
73+
import translationLanguageCode from './language-code/translation.json';
74+
```
75+
76+
2. Add it to the `resources` object:
77+
```typescript
78+
export const resources = {
79+
// ... existing languages
80+
'language-code': { translation: translationLanguageCode },
81+
} as const;
82+
```
83+
84+
Example:
85+
```typescript
86+
import translationBo from './bo/translation.json';
87+
import translationUk from './uk/translation.json';
88+
89+
export const resources = {
90+
// ... existing languages
91+
bo: { translation: translationBo },
92+
uk: { translation: translationUk },
93+
} as const;
94+
```
95+
96+
### 6. Handle Fallback Languages (Optional)
97+
98+
If your language should fall back to a specific language when translations are missing, update the `fallbackLng` configuration in `i18n.ts`:
99+
100+
```typescript
101+
fallbackLng: {
102+
'language-variant': ['fallback-language', 'en'],
103+
// ... existing fallbacks
104+
},
105+
```
106+
107+
## Translation Process
108+
109+
After adding a new language:
110+
111+
1. The empty translation file will be populated through LibreChat's automated translation platform
112+
2. Only the English (`en`) translation file should be manually updated
113+
3. Other language translations are managed externally
114+
115+
## Language Code Standards
116+
117+
- Use ISO 639-1 codes for most languages (e.g., `en`, `fr`, `de`)
118+
- Use ISO 639-1 with region codes when needed (e.g., `pt-BR`, `zh-Hans`)
119+
- Tibetan uses `bo` (Bodic)
120+
- Ukrainian uses `uk` or `uk-UA` with region
121+
122+
## Testing
123+
124+
After adding a new language:
125+
126+
1. Restart the development server
127+
2. Navigate to Settings > General
128+
3. Verify your language appears in the dropdown
129+
4. Select it to ensure it changes the UI language code
130+
131+
## Notes
132+
133+
- Keep language options alphabetically sorted in the dropdown for better UX
134+
- Always use native script for language names in the dropdown
135+
- The system will use English as fallback for any missing translations
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

client/src/locales/en/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,10 @@
435435
"com_nav_lang_spanish": "Español",
436436
"com_nav_lang_swedish": "Svenska",
437437
"com_nav_lang_thai": "ไทย",
438+
"com_nav_lang_tibetan": "བོད་སྐད་",
438439
"com_nav_lang_traditional_chinese": "繁體中文",
439440
"com_nav_lang_turkish": "Türkçe",
441+
"com_nav_lang_ukrainian": "Українська",
440442
"com_nav_lang_uyghur": "Uyƣur tili",
441443
"com_nav_lang_vietnamese": "Tiếng Việt",
442444
"com_nav_language": "Language",

client/src/locales/i18n.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import translationHy from './hy/translation.json';
3535
import translationFi from './fi/translation.json';
3636
import translationZh_Hans from './zh-Hans/translation.json';
3737
import translationZh_Hant from './zh-Hant/translation.json';
38+
import translationBo from './bo/translation.json';
39+
import translationUk from './uk/translation.json';
3840

3941
export const defaultNS = 'translation';
4042

@@ -71,6 +73,8 @@ export const resources = {
7173
hu: { translation: translationHu },
7274
hy: { translation: translationHy },
7375
fi: { translation: translationFi },
76+
bo: { translation: translationBo },
77+
uk: { translation: translationUk },
7478
} as const;
7579

7680
i18n
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)