From bc43423f581daf70221c9043a20f817689d2a781 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sat, 2 Aug 2025 12:37:18 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8D=20i18n:=20Add=20Tibetan=20and=20Uk?= =?UTF-8?q?rainian=20languages=20to=20localization=20(#8819)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🌍 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 --- .../Nav/SettingsTabs/General/General.tsx | 2 + client/src/locales/README.md | 135 ++++++++++++++++++ client/src/locales/bo/translation.json | 1 + client/src/locales/en/translation.json | 2 + client/src/locales/i18n.ts | 4 + client/src/locales/uk/translation.json | 1 + 6 files changed, 145 insertions(+) create mode 100644 client/src/locales/README.md create mode 100644 client/src/locales/bo/translation.json create mode 100644 client/src/locales/uk/translation.json diff --git a/client/src/components/Nav/SettingsTabs/General/General.tsx b/client/src/components/Nav/SettingsTabs/General/General.tsx index 886867980a..a746c4cf71 100644 --- a/client/src/components/Nav/SettingsTabs/General/General.tsx +++ b/client/src/components/Nav/SettingsTabs/General/General.tsx @@ -105,6 +105,8 @@ export const LangSelector = ({ { value: 'nl-NL', label: localize('com_nav_lang_dutch') }, { value: 'id-ID', label: localize('com_nav_lang_indonesia') }, { value: 'fi-FI', label: localize('com_nav_lang_finnish') }, + { value: 'bo', label: localize('com_nav_lang_tibetan') }, + { value: 'uk-UA', label: localize('com_nav_lang_ukrainian') }, ]; return ( diff --git a/client/src/locales/README.md b/client/src/locales/README.md new file mode 100644 index 0000000000..aa40db0f42 --- /dev/null +++ b/client/src/locales/README.md @@ -0,0 +1,135 @@ +# LibreChat Localization Guide + +This guide explains how to add new languages to LibreChat's localization system. + +## Adding a New Language + +To add a new language to LibreChat, follow these steps: + +### 1. Add the Language to Locize Project + +- Navigate to the [LibreChat locize project](https://www.locize.app/cat/62uyy7c9), +- Click the "ADD LANGUAGE" button, typically found within the "..." menu of the "Start to translate" card on the project overview page. + +### 2. Update the Language Selector Component + +Edit `client/src/components/Nav/SettingsTabs/General/General.tsx` and add your new language option to the `languageOptions` array: + +```typescript +{ value: 'language-code', label: localize('com_nav_lang_language_name') }, +``` + +Example: +```typescript +{ value: 'bo', label: localize('com_nav_lang_tibetan') }, +{ value: 'uk-UA', label: localize('com_nav_lang_ukrainian') }, +``` + +**Note:** Use the appropriate language code format: +- Use simple codes (e.g., `bo`) for languages without regional variants +- Use region-specific codes (e.g., `uk-UA`) when needed + +### 3. Add Localization Keys + +In `client/src/locales/en/translation.json`, add the corresponding localization key for your language label: + +```json +"com_nav_lang_language_name": "Native Language Name", +``` + +Example: +```json +"com_nav_lang_tibetan": "བོད་སྐད་", +"com_nav_lang_ukrainian": "Українська", +``` + +**Best Practice:** Use the native language name as the value. + +### 4. Create the Translation File + +Create a new directory and translation file: + +```bash +mkdir -p client/src/locales/[language-code] +``` + +Create `client/src/locales/[language-code]/translation.json` with an empty JSON object: + +```json +{ +} +``` + +Example: +- `client/src/locales/bo/translation.json` +- `client/src/locales/uk/translation.json` + +### 5. Configure i18n + +Update `client/src/locales/i18n.ts`: + +1. Import the new translation file: +```typescript +import translationLanguageCode from './language-code/translation.json'; +``` + +2. Add it to the `resources` object: +```typescript +export const resources = { + // ... existing languages + 'language-code': { translation: translationLanguageCode }, +} as const; +``` + +Example: +```typescript +import translationBo from './bo/translation.json'; +import translationUk from './uk/translation.json'; + +export const resources = { + // ... existing languages + bo: { translation: translationBo }, + uk: { translation: translationUk }, +} as const; +``` + +### 6. Handle Fallback Languages (Optional) + +If your language should fall back to a specific language when translations are missing, update the `fallbackLng` configuration in `i18n.ts`: + +```typescript +fallbackLng: { + 'language-variant': ['fallback-language', 'en'], + // ... existing fallbacks +}, +``` + +## Translation Process + +After adding a new language: + +1. The empty translation file will be populated through LibreChat's automated translation platform +2. Only the English (`en`) translation file should be manually updated +3. Other language translations are managed externally + +## Language Code Standards + +- Use ISO 639-1 codes for most languages (e.g., `en`, `fr`, `de`) +- Use ISO 639-1 with region codes when needed (e.g., `pt-BR`, `zh-Hans`) +- Tibetan uses `bo` (Bodic) +- Ukrainian uses `uk` or `uk-UA` with region + +## Testing + +After adding a new language: + +1. Restart the development server +2. Navigate to Settings > General +3. Verify your language appears in the dropdown +4. Select it to ensure it changes the UI language code + +## Notes + +- Keep language options alphabetically sorted in the dropdown for better UX +- Always use native script for language names in the dropdown +- The system will use English as fallback for any missing translations diff --git a/client/src/locales/bo/translation.json b/client/src/locales/bo/translation.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/client/src/locales/bo/translation.json @@ -0,0 +1 @@ +{} diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index ae61f049a8..67fa367b15 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -435,8 +435,10 @@ "com_nav_lang_spanish": "Español", "com_nav_lang_swedish": "Svenska", "com_nav_lang_thai": "ไทย", + "com_nav_lang_tibetan": "བོད་སྐད་", "com_nav_lang_traditional_chinese": "繁體中文", "com_nav_lang_turkish": "Türkçe", + "com_nav_lang_ukrainian": "Українська", "com_nav_lang_uyghur": "Uyƣur tili", "com_nav_lang_vietnamese": "Tiếng Việt", "com_nav_language": "Language", diff --git a/client/src/locales/i18n.ts b/client/src/locales/i18n.ts index 223872fe67..9af02cef39 100644 --- a/client/src/locales/i18n.ts +++ b/client/src/locales/i18n.ts @@ -35,6 +35,8 @@ import translationHy from './hy/translation.json'; import translationFi from './fi/translation.json'; import translationZh_Hans from './zh-Hans/translation.json'; import translationZh_Hant from './zh-Hant/translation.json'; +import translationBo from './bo/translation.json'; +import translationUk from './uk/translation.json'; export const defaultNS = 'translation'; @@ -71,6 +73,8 @@ export const resources = { hu: { translation: translationHu }, hy: { translation: translationHy }, fi: { translation: translationFi }, + bo: { translation: translationBo }, + uk: { translation: translationUk }, } as const; i18n diff --git a/client/src/locales/uk/translation.json b/client/src/locales/uk/translation.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/client/src/locales/uk/translation.json @@ -0,0 +1 @@ +{}