LibreChat/docs/contributions/translation_contribution.md

119 lines
3.9 KiB
Markdown
Raw Normal View History

🧹📚 docs: refactor and clean up (#1392) * 📑 update mkdocs * rename docker override file and add to gitignore * update .env.example - GOOGLE_MODELS * update index.md * doc refactor: split installation and configuration in two sub-folders * doc update: installation guides * doc update: configuration guides * doc: new docker override guide * doc: new beginner's guide for contributions - Thanks @Berry-13 * doc: update documentation_guidelines.md * doc: update testing.md * doc: update deployment guides * doc: update /dev readme * doc: update general_info * doc: add 0 value to doc weight * doc: add index.md to every doc folders * doc: add weight to index.md and move openrouter from free_ai_apis.md to ai_setup.md * doc: update toc so they display properly on the right had side in mkdocs * doc: update pandoranext.md * doc: index logging_system.md * doc: update readme.md * doc: update litellm.md * doc: update ./dev/readme.md * doc:🔖 new presets.md * doc: minor corrections * doc update: user_auth_system.md and presets.md, doc feat: add mermaid support to mkdocs * doc update: add screenshots to presets.md * doc update: add screenshots to - OpenID with AWS Cognito * doc update: BingAI cookie instruction * doc update: discord auth * doc update: facebook auth * doc: corrections to user_auth_system.md * doc update: github auth * doc update: google auth * doc update: auth clean up * doc organization: installation * doc organization: configuration * doc organization: features+plugins & update:plugins screenshots * doc organization: deploymend + general_info & update: tech_stack.md * doc organization: contributions * doc: minor fixes * doc: minor fixes
2023-12-22 08:36:42 -05:00
---
title: 🌍 Contribute a Translation
description: How to add a new language to LibreChat.
🧹📚 docs: refactor and clean up (#1392) * 📑 update mkdocs * rename docker override file and add to gitignore * update .env.example - GOOGLE_MODELS * update index.md * doc refactor: split installation and configuration in two sub-folders * doc update: installation guides * doc update: configuration guides * doc: new docker override guide * doc: new beginner's guide for contributions - Thanks @Berry-13 * doc: update documentation_guidelines.md * doc: update testing.md * doc: update deployment guides * doc: update /dev readme * doc: update general_info * doc: add 0 value to doc weight * doc: add index.md to every doc folders * doc: add weight to index.md and move openrouter from free_ai_apis.md to ai_setup.md * doc: update toc so they display properly on the right had side in mkdocs * doc: update pandoranext.md * doc: index logging_system.md * doc: update readme.md * doc: update litellm.md * doc: update ./dev/readme.md * doc:🔖 new presets.md * doc: minor corrections * doc update: user_auth_system.md and presets.md, doc feat: add mermaid support to mkdocs * doc update: add screenshots to presets.md * doc update: add screenshots to - OpenID with AWS Cognito * doc update: BingAI cookie instruction * doc update: discord auth * doc update: facebook auth * doc: corrections to user_auth_system.md * doc update: github auth * doc update: google auth * doc update: auth clean up * doc organization: installation * doc organization: configuration * doc organization: features+plugins & update:plugins screenshots * doc organization: deploymend + general_info & update: tech_stack.md * doc organization: contributions * doc: minor fixes * doc: minor fixes
2023-12-22 08:36:42 -05:00
weight: -8
---
2023-08-26 19:36:25 -04:00
# 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 for Contributors - GitHub](./how_to_contribute.md#github)
2023-08-26 19:36:25 -04:00
### Add your language to `Translation.tsx`:
- Navigate to the `client\src\localization` folder and open the `Translation.tsx` file
- At the beginning of the code, add your language below all the others in this format:
`import Language-name from './languages/** ';`
2023-08-26 19:36:25 -04:00
Example (English):`import English from './languages/Eng';`
- Further down in the code, add in the language mapping, the following:
`'**-**': LanguageName,`
2023-08-26 19:36:25 -04:00
> Replace `**-**` with the local identifier of your language (ask ChatGPT or search it on Google).
2023-08-26 19:36:25 -04:00
> Replace `LanguageName` with the name of your language.
2023-08-26 19:36:25 -04:00
Example (English): `'en-US': English,`
2023-08-26 19:36:25 -04:00
### 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:
```js title="Eng.tsx"
2023-08-26 19:36:25 -04:00
// your-language-name phrases
export default {
com_ui_examples: 'Examples',
// more translations here...
```
__Translate only the part after the `:`.__
Example:
```js title="**.tsx (new language)"
2023-08-26 19:36:25 -04:00
// my-language phrases
export default {
com_ui_examples: 'This is a translated example',
// Add more translations here
};
```
!!! warning
Do not modify the `com_...` part
2023-08-26 19:36:25 -04:00
!!! success "Important:"
- 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)
2023-08-26 19:36:25 -04:00
### 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.tsx`.
- Add your language to the `LangSelector` variable in the following way:
2023-08-26 19:36:25 -04:00
```js title="LangSelector"
2023-08-26 19:36:25 -04:00
export const LangSelector = ({
//other code
<option value="en-US">{localize(lang, 'com_nav_lang_english')}</option>
2023-08-26 19:36:25 -04:00
//other languages...
<option value="**">{localize(lang, 'com_nav_lang_your-language-name')}</option>
</select>
</div>
);
};
```
!!! note
`**-**` 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`
2023-08-26 19:36:25 -04:00
**You should only need to add one line of code:**
```js
<option value="**-**">{localize(lang, 'com_nav_lang_your-language-name')}</option>
2023-08-26 19:36:25 -04:00
```
### Summary
If you followed everything you should have ^^**one new file**^^ and ^^**3 modified files**^^:
2023-08-26 19:36:25 -04:00
```bash
new file: client/src/localization/languages/**.tsx <-----new language
modified: client/src/components/Nav/SettingsTabs/General.tsx
modified: client/src/localization/Translation.tsx
modified: client/src/localization/languages/Eng.tsx
2023-08-26 19:36:25 -04:00
```
!!! tip
You can confirm this by using the following command: `git status`
2023-08-26 19:36:25 -04:00
### Commit and create a new PR
See: [Make a PR](./how_to_contribute.md#make-a-pull-request-pr)
2023-08-26 19:36:25 -04:00
!!! success "Pull Request"
- 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 😎