From f4e16af5db8441c2e1141b82ab73d04d3d5b701e Mon Sep 17 00:00:00 2001 From: Ruben Talstra Date: Mon, 10 Feb 2025 15:05:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8E=20i18n:=20Translation=20Docs=20(#2?= =?UTF-8?q?32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added new translation docs. removed old /development/translation.mdx file to make it more accessible to find. * refactor: table to right format. * fix: cleaned up some code * updated: created per language an invitation key --- pages/docs/_meta.ts | 1 + pages/docs/development/_meta.ts | 1 - pages/docs/development/translation.mdx | 128 ------------ pages/docs/translation/_meta.ts | 3 + pages/docs/translation/index.mdx | 258 +++++++++++++++++++++++++ 5 files changed, 262 insertions(+), 129 deletions(-) delete mode 100644 pages/docs/development/translation.mdx create mode 100644 pages/docs/translation/_meta.ts create mode 100644 pages/docs/translation/index.mdx diff --git a/pages/docs/_meta.ts b/pages/docs/_meta.ts index 0e57397..3c04b95 100644 --- a/pages/docs/_meta.ts +++ b/pages/docs/_meta.ts @@ -16,6 +16,7 @@ export default { remote: '☁️ Remote Hosting', configuration: '⚙️ Configuration', user_guides: '📘 User Guides', + translation: '🌍 Translation', contributing: { // "title": "Contributing", type: 'separator', diff --git a/pages/docs/development/_meta.ts b/pages/docs/development/_meta.ts index f2feef0..d8f3f0f 100644 --- a/pages/docs/development/_meta.ts +++ b/pages/docs/development/_meta.ts @@ -1,7 +1,6 @@ export default { index: 'Intro', get_started: 'Get Started', - translation: 'Translation', tools_and_plugins: 'Tools and Plugins', testing: 'Testing', debugging: 'Debugging (WIP)', diff --git a/pages/docs/development/translation.mdx b/pages/docs/development/translation.mdx deleted file mode 100644 index fd7ff52..0000000 --- a/pages/docs/development/translation.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -title: Contribute a Translation -description: How to add a new language to LibreChat. ---- - -# How to add a new language to LibreChat 🌍 - -## Minimum Requirements: - -1. Good knowledge of the language (some terms may undergo significant changes during translation) -2. A text editor is required. While options like Notepad or Notepad++ are available, it is recommended to use **[VSCode](https://code.visualstudio.com/download)** as it is more suitable for this task.. - -## Language Translation - -### Preparation - -Fork the [LibreChat repository](https://github.librechat.ai) and download it using git clone. See: [Getting Started - GitHub](/docs/development/get_started#github) - -### Add your language to `Translation.ts`: - -- Navigate to the `client\src\localization` folder and open the `Translation.ts` file - -- At the beginning of the code, add your language below all the others in this format: - - `import Language-name from './languages/** ';` - - Example (English):`import English from './languages/Eng';` - -- Further down in the code, add in the language mapping, the following: - - `'**-**': LanguageName,` - -> Replace `**-**` with the local identifier of your language (ask ChatGPT or search it on Google). -> Replace `LanguageName` with the name of your language. - -Example (English): `'en-US': English,` - -### Create your new language file - -- Go into the `client\src\localization\languages` folder and create a file named as follows: `**.tsx` - - Example: `Eng.tsx` - -- Copy all the content from `Eng.tsx` into your file and modify it as follows: - - ```ts filename="Eng.tsx" - // your-language-name phrases - - export default { - com_ui_examples: 'Examples', - // more translations here... - ``` - - **Translate only the part after the `:`.** - Example: - - ```ts filename="**.tsx (new language)" - // my-language phrases - - export default { - com_ui_examples: 'This is a translated example', - // Add more translations here - } - ``` - - - Do not modify the `com_...` part - - - - - Delete the Language list after `com_nav_setting_general: 'General',` near the bottom of the file - (You do not need to translate the individual language names) - Do not delete - `com_nav_setting_data: 'Data controls'` (you need to translate it) - - -### Add your language to `Eng.tsx` - -Open `Eng.tsx` and add your language to the language list in the bottom of the document. - -### Add your language to the menu - -- Navigate to the file `client\src\components\Nav\SettingsTabs\General\General.tsx`. -- Add your language to the `LangSelector` variable in the following way: - - ```ts filename="LangSelector" - export const LangSelector = ({ - //other code - - //other languages... - - - - ); - }; - ``` - - - `**-**` is the local identifier of your language and `com_nav_lang_your-language-name` stands for - the name of your language. Example: `com_nav_lang_english` or `com_nav_lang_italian` - - -**You should only need to add one line of code:** - -```ts - -``` - -### Summary - -If you followed everything you should have **one new file** and **3 modified files**: - -```bash - new file: client/src/localization/languages/**.tsx <-----new language - modified: client/src/components/Nav/SettingsTabs/General/General.tsx - modified: client/src/localization/Translation.ts - modified: client/src/localization/languages/Eng.tsx -``` - -You can confirm this by using the following command: `git status` - -### Commit and create a new PR - -See: [Make a PR](/docs/development/get_started#create-a-pull-request-pr) - - - - Answer all the questions, and in the "Type of Change" section, check `- [x] Translation update` - - **Delete irrelevant comments** from the PR template - Create a pull request 😎 - diff --git a/pages/docs/translation/_meta.ts b/pages/docs/translation/_meta.ts new file mode 100644 index 0000000..62aacc4 --- /dev/null +++ b/pages/docs/translation/_meta.ts @@ -0,0 +1,3 @@ +export default { + index: 'Intro', +} diff --git a/pages/docs/translation/index.mdx b/pages/docs/translation/index.mdx new file mode 100644 index 0000000..9013e10 --- /dev/null +++ b/pages/docs/translation/index.mdx @@ -0,0 +1,258 @@ +--- +title: Intro +description: A guide to contributing translations for LibreChat. +--- + +# Translation Guide + +Thank you for your interest in translating LibreChat! We rely on community contributions to make our application accessible to users around the globe. All translations are managed via [Locize](https://locize.com), a robust translation management system that seamlessly integrates with our project. + +## How Translations Work + +- **Centralized Management:** +All translation strings for LibreChat are maintained in one location on Locize. This centralization ensures consistency and simplifies updates across the entire application. + +- **Automatic Updates:** +Changes made in Locize are automatically synchronized with our project. You can monitor the translation progress for each language through dynamic badges in our repository. + +- **Community Driven:** +We welcome contributions in every language. Your help makes LibreChat accessible to a broader audience and supports users in their native languages. + + + +## Translation Progress + +Below is our current translation progress for some of the supported languages. Feel free to check these badges and help us improve the translations further: + +| Language | Translation Progress Badge | +|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **English (en)** | EN Badge | +| **Arabic (ar)** | AR Badge | +| **German (de)** | DE Badge | +| **Spanish (es)** | ES Badge | +| **Estonian (et)** | ET Badge | +| **Finnish (fi)** | FI Badge | +| **French (fr)** | FR Badge | +| **Hebrew (he)** | HE Badge | +| **Indonesian (id)** | ID Badge | +| **Italian (it)** | IT Badge | +| **Japanese (ja)** | JA Badge | +| **Korean (ko)** | KO Badge | +| **Dutch (nl)** | NL Badge | +| **Polish (pl)** | PL Badge | +| **Portuguese (pt)** | PT Badge | +| **Russian (ru)** | RU Badge | +| **Swedish (sv)** | SV Badge | +| **Turkish (tr)** | TR Badge | +| **Vietnamese (vi)** | VI Badge | +| **Chinese (Simplified) (zh)** | ZH Badge | +| **Chinese (Traditional) (zh-Hant)** | ZH-HANT Badge | + +--- + + + +## Getting Started + +Before you begin translating, please follow the steps below to set up your Locize account and start contributing. + + + + +### Step 1: Create a Locize Account + +1. Visit the Registration Page + + Choose your preferred language and click the corresponding link to register: + + - **[English (en)](https://www.locize.app/register?invitation=tTHVYwI9TzWuOeJnKyWxSuuaDrSS5TsZqRh0BAHzebuuljz5OUXnlqbksio5WnXp)** + - **[Arabic (ar)](https://www.locize.app/register?invitation=Cn7hc6teYyY89nvQdosfXkubbj2MZi2XMzcxUP6fGglcPkAgd1AwS5Pfbr1Wu4lz)** + - **[German (de)](https://www.locize.app/register?invitation=rAXIyYNuO53txcygphdOClUR5YnNccd1MZ1Vs66p4ziOqHfM3MFiKnymdK6wLMpW)** + - **[Spanish (es)](https://www.locize.app/register?invitation=gkrRvUjxvFnRfUtynbaREj2zdbvd2FU95OFGcixGMOkcCxSwmrvOBclBZJWmERw6)** + - **[Estonian (et)](https://www.locize.app/register?invitation=q1ye9gNpYsVKvs2JS5CEjp4SBy6ovq2aUeIhAMsRoW2iVcdfxpc4GiOaHGDV85VZ)** + - **[Finnish (fi)](https://www.locize.app/register?invitation=weERAttD7ax0Zfo5w9LyfWbaP50WPbS4Vk7BF1P6wM0fe5Q0xlrJACVjTAGbkv2c)** + - **[French (fr)](https://www.locize.app/register?invitation=wz5EbZiwE9Bxev4TTAyG09PKvnFSQoOaLomxVgEKOyaLhm9oCDdhDi4TkJp8rcq5)** + - **[Hebrew (he)](https://www.locize.app/register?invitation=3LSHQxUsHYumNhw5ZJNu6Re6x699i6RGnpdKzt2BrDeNFNObxjj2lKXfZFUhb1jP)** + - **[Indonesian (id)](https://www.locize.app/register?invitation=S94A2D6glr7w64Nf27XwmvzkcnTRAWhxFoxcl7ZRnmm1dMx23kfpZCx8ROlqb6X2)** + - **[Italian (it)](https://www.locize.app/register?invitation=LI6zvAH82797Gro6lc490d34zrw8vthQPdN01n9nfk2c1LW5VVpf4Db6WL5GFHir)** + - **[Japanese (ja)](https://www.locize.app/register?invitation=VVJLuv7WjjBs0wShxZheCIvwzk7XszVsHCAMZmCQ34SJYrwIeB1GW6u2vkYNJdzk)** + - **[Korean (ko)](https://www.locize.app/register?invitation=nbL4LZMwehlTvFKNmNGgTTJt9YsZuuyCMjF9yAc92bVIWEjAc9C1G0ujsEl76dYb)** + - **[Dutch (nl)](https://www.locize.app/register?invitation=BQoligTqND5E4jlGmXJZVzkLOpo4pTf9wUyN19zZbgNB38JHaciJ2FnIbsLOXPbe)** + - **[Polish (pl)](https://www.locize.app/register?invitation=ZPiib1OoPM3OHBUow79I8iQNiFk4SHO7HASO3rHdJpKSlJwA4oxsORR2w4yJaPig)** + - **[Portuguese (pt)](https://www.locize.app/register?invitation=pqrsp34qWe3KFmnd2GgYVklyML5d7T1mcb27RCqPgYRYSmm6qiQFvTqUy2koUDQ0)** + - **[Russian (ru)](https://www.locize.app/register?invitation=rz4C3pVFdfr5XPPNTsYJvjjnC7vHDVWVOfyUzCf33MxhccdYB7vM7jxcHLacGl14)** + - **[Swedish (sv)](https://www.locize.app/register?invitation=RYtYhip5O5ACNCth1cIZpByGnZC1b3JttimEe8mrz5NDyEjVAs1PVcMIQ1in4j7D)** + - **[Turkish (tr)](https://www.locize.app/register?invitation=x3Ov59Gdrk2b76gn5pSVCwuekDs817YOYElXJn9zCYClPG2XlBORQDRygZmdBH4B)** + - **[Vietnamese (vi)](https://www.locize.app/register?invitation=rhADX8GuhgQmYrmbHT13YVg2WqMLJpgPdh1OBuujn9GoNUVW6RPipYvC20aH1xcQ)** + - **[Chinese (Simplified) (zh)](https://www.locize.app/register?invitation=6TRX7enwmxfmmIWy1SG6BhkWmQdktk4V2DIyF4n7t6SIlFjoZ5lIzhhXy4r0evR7)** + - **[Chinese (Traditional) (zh-Hant)](https://www.locize.app/register?invitation=9PWBDcMascIBGG6wwobkVT6cL7p7IncFZVqwIe0e7VZd14MJOAMQGk6IjlvgmA00)** + + +2. **Fill in Your Details:** +Enter your email, password, and any other required information, then click **Sign Up**. + +![Create Account](https://github.com/user-attachments/assets/c1ccbfd9-2131-4020-a4b3-7283bf733828) + + + +### Step 2: Explore the Locize Dashboard + +After signing up, you’ll be directed to the Locize dashboard, where you can see an overview of the translation project. + +- **Dashboard Overview:** +This page displays the available languages and progress statistics for the project. + +![Landing Page](https://github.com/user-attachments/assets/818b3d30-3f5a-48e6-8b36-0be3d0691045) + + + +### Step 3: Select Your Language + +1. **Open the Language Dropdown:** +Click the dropdown menu that lists all supported languages. + +2. **Choose Your Preferred Language:** +For example, if you want to translate into Dutch, scroll down and select **Dutch**. + +![Dropdown with Languages](https://github.com/user-attachments/assets/93f713bd-0008-43bc-ba84-b7730d4cfedf) + + + +### Step 4: Navigate to the Translation Page + +After selecting your language, click on the translation progress indicator (for example, "35.61% translated"). This will take you to the page where you can contribute translations. + +![Selected Dutch Click on Translation](https://github.com/user-attachments/assets/03322ab5-82ad-4958-9008-5e7e17363ca8) + + + +### Step 5: Contribute Your Translation + +1. **Browse the Translation Strings:** +The interface displays a list of translation keys along with their original texts. + +2. **Select a String to Translate:** +Click on the string you wish to work on. + +3. **Enter Your Translation:** +Type your translated text into the input field provided next to the original text. + +4. **Review Your Work:** +Ensure that your translation is accurate and clear. + +![Start with Translating](https://github.com/user-attachments/assets/bc3e2a47-c297-476e-945b-f7f0b1356ffb) + + + +### Step 6: Save and Submit Your Translation + +1. **Submit Your Translation:** +Once you’re satisfied with your translation, click the **Save** button to submit it for review. + +2. **Pending Review:** +Your submitted translation will be marked as pending and will be reviewed by project maintainers. + +![Saved Submitted Translation Waiting for Review](https://github.com/user-attachments/assets/a26ae981-0c32-47a0-a296-530ce671375a) + + + +### Step 7: Translation Approval + +After review, your translation will be approved and integrated into the project. + +- **Approved Translation:** +Once approved, your contribution will be reflected in the Locize dashboard and the overall translation progress. + +![Translation Approved](https://github.com/user-attachments/assets/93c3e512-616f-40d9-af2f-9f7c19d53148) + +--- + +## Handling `{{0}}` and `{{1}}` in Translation Strings + +Sometimes translation strings need to include dynamic content. These dynamic parts, called **interpolations**, are represented by placeholders enclosed in double curly brackets (e.g., `{{0}}` or `{{1}}`). When translating such strings, it's important to maintain these placeholders in the correct positions. + +Below are two examples to help guide you: + +### Example 1: Single Interpolation + +Consider the translation key `com_assistants_completed_action`. The original English text is: + +```text +Talked to {{0}} +``` + +For the German translation, ensure the placeholder remains intact and is placed appropriately: + +```text +Mit {{0}} gesprochen +``` + +This image shows how a single interpolation is represented in a translation string: + +![Single Interpolation](https://github.com/user-attachments/assets/384ef7c1-9b02-490c-8ca4-b7f74943893f) + +--- + +### Example 2: Multiple Interpolations + +Now, look at the translation key `com_files_number_selected`, which includes two placeholders. The English version is: + +```text +{{0}} of {{1}} item(s) selected +``` + +In the German translation, both placeholders must be preserved and positioned correctly: + +```text +{{0}} von {{1}} Datei(en) ausgewählt +``` + +This image illustrates how multiple interpolations appear in translation strings: + +![Multiple Interpolations](https://github.com/user-attachments/assets/f3376487-e092-442a-b849-b6ab5d5b390d) + +--- + + +## Adding a New Language + +If you don't see your language listed in our translation table, you can help us expand our language support: + +1. **Create a New Issue:** +Open a new issue in our GitHub repository: [LibreChat Issues](https://github.com/danny-avila/LibreChat/issues). + +2. **Select the New Language Request Template:** +Use the **New Language Request** template and provide: + - The full name of your language (e.g., Spanish, Mandarin). + - The [ISO 639-1](https://www.w3schools.com/tags/ref_language_codes.asp) code for your language (e.g., `es` for Spanish). + +3. **Collaborate with Maintainers:** +Our maintainers will review your request and work with you to integrate the new language. Once approved, your language will appear in the translation progress table, and you can start contributing. + +--- + +## Need Help? + +If you have any questions or need assistance, please feel free to: + +- **Open an Issue:** +Submit an issue in our repository: [LibreChat Issues](https://github.com/danny-avila/LibreChat/issues). + +- **Join Our Discord Community:** +Connect with fellow translators on our [Discord server](https://discord.librechat.ai). + +- **Contact a Maintainer:** +Reach out directly to one of our project maintainers for additional support. + +Your contributions help make LibreChat accessible to users worldwide. Thank you for supporting our project, and happy translating! + + +--- + +We thank [Locize](https://locize.com) for their translation management tools that support multiple languages in LibreChat. + +

+ + Locize Logo + +

\ No newline at end of file