mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-08 18:44:22 +01:00
docs: updates (#841)
This commit is contained in:
parent
39c626aa8e
commit
29d3640546
9 changed files with 162 additions and 204 deletions
|
|
@ -1,80 +0,0 @@
|
|||
# How to add a language to LibreChat
|
||||
|
||||
## Minimum Requirements:
|
||||
|
||||
1. Good knowledge of the language (some terms may undergo significant changes during translation)
|
||||
2. An editor, which can be Notepad or (**recommended**: [VSCode](https://code.visualstudio.com/download))
|
||||
|
||||
## Language translation
|
||||
|
||||
|
||||
1. Fork the LibreChat repository and download it using git clone https://github.com/danny-avila/LibreChat
|
||||
2. Navigate to the "client\src\localization" folder and open the "Translation.tsx" file
|
||||
3. At the beginning of the code, add your language below all the others in this format:
|
||||
|
||||
`import Language-name from './languages/** ';`
|
||||
|
||||
For example, let's take English as an example:
|
||||
|
||||
Note: Replace "LanguageName" with the name of your language (capitalized) and "**" with the ISO 3166 Alpha-2 code of your country (the initial of the nation).
|
||||
If you don't know the ISO 3166 code for your language, check it [here](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) and also use it with an initial capital)
|
||||
|
||||
4. Further down in the code, add the following
|
||||
|
||||
`if (langCode === '**') return Language-name;`
|
||||
|
||||
Replace "**" with the ISO 3166 Alpha-2 code of your language (in lowercase). Here's an example: `if (langCode === 'en') return English;`)
|
||||
|
||||
7.Go into the "languages" folder and create a file named as follows: **.tsx
|
||||
|
||||
For example: En.tsx
|
||||
|
||||
9. Copy all the content from En.tsx into your file and modify it as follows:
|
||||
|
||||
```
|
||||
// your-language-name phrases
|
||||
|
||||
export default {
|
||||
com_ui_examples: 'Examples',
|
||||
// Add more translations here
|
||||
```
|
||||
|
||||
Rename only the part after the colon ":" to the corresponding translation in your language. For example:
|
||||
|
||||
```
|
||||
// my-language phrases
|
||||
|
||||
export default {
|
||||
com_ui_examples: 'WORD_THAT_I_TRANSLATE_IN_TO_MY_LANGUAGE',
|
||||
// Add more translations here
|
||||
};
|
||||
```
|
||||
|
||||
⚠️DO NOT CHANGE com_... ⚠️
|
||||
|
||||
10. To add your language to the menu, open the file "client\src\components\Nav\SettingsTabs\General.tsx" and add your language to the "LangSelector" variable in the following way:
|
||||
|
||||
```
|
||||
export const LangSelector = ({
|
||||
//other code
|
||||
<option value="en">{localize(lang, 'com_nav_lang_english')}</option>
|
||||
//other languages...
|
||||
<option value="**">{localize(lang, 'com_nav_lang_your-language-name')}</option>
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
where ** is the ISO 3166 Alpha-2 code and "com_nav_lang_your-language-name" stands for the name in your language (for example com_nav_lang_english or com_nav_lang_italian)
|
||||
The only line of code to add is:
|
||||
|
||||
`<option value="**">{localize(lang, 'com_nav_lang_your-language-name')}</option>`
|
||||
|
||||
11. Commit your changes using git add *, git commit -m "Language translation: your-language translation" and git push.
|
||||
12. Open your repository in a browser and click on "Contribute"
|
||||
|
||||

|
||||
|
||||
14. Answer all the questions, and in the "Type of Change" section, add `- [x] Translation support`
|
||||
15. Create a pull request 🎉
|
||||
113
docs/contributions/translation_contribution.md
Normal file
113
docs/contributions/translation_contribution.md
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# 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.com/danny-avila/LibreChat) and download it using git clone
|
||||
|
||||
### 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/** ';`
|
||||
Example (English):`import English from './languages/Eng';`
|
||||
|
||||
- Further down in the code, add the following:
|
||||
|
||||
`if (langCode === '**') return Language-name;`
|
||||
|
||||
>Replace "**" with the ISO 3166 Alpha-2 code of your language (in lowercase).
|
||||
Example (English): `if (langCode === 'en') return English;`
|
||||
|
||||
>If you don't know the ISO 3166 code for your language, check it [here](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) and also use it with an initial capital)
|
||||
|
||||
### 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
|
||||
// your-language-name phrases
|
||||
|
||||
export default {
|
||||
com_ui_examples: 'Examples',
|
||||
// more translations here...
|
||||
```
|
||||
|
||||
__Translate only the part after the `:`.__
|
||||
Example:
|
||||
|
||||
```js
|
||||
// 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)
|
||||
|
||||
|
||||
### 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
|
||||
To add your language to the menu, open the file `client\src\components\Nav\SettingsTabs\General.tsx`.
|
||||
Add your language to the `LangSelector` variable in the following way:
|
||||
|
||||
```js
|
||||
export const LangSelector = ({
|
||||
//other code
|
||||
<option value="en">{localize(lang, 'com_nav_lang_english')}</option>
|
||||
//other languages...
|
||||
<option value="**">{localize(lang, 'com_nav_lang_your-language-name')}</option>
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
Where `**` is the ISO 3166 Alpha-2 code 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:**
|
||||
```js
|
||||
<option value="**">{localize(lang, 'com_nav_lang_your-language-name')}</option>
|
||||
```
|
||||
|
||||
### Summary
|
||||
If you followed everything you should have __one__ new file and __3__ files with modifications:
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
You can confirm this by using the following command: `git status`
|
||||
|
||||
### Commit and create a new PR
|
||||
- Commit your changes using:
|
||||
- `git add *`
|
||||
- `git commit -m "Language translation: your-language translation"`
|
||||
- `git push`
|
||||
|
||||
- Open your repository in a browser and click on "Contribute"
|
||||
|
||||

|
||||
|
||||
- Answer all the questions, and in the "Type of Change" section, add `- [x] Translation support`
|
||||
- Delete irrelevant comments from the template
|
||||
- Create a pull request 🎉
|
||||
Loading…
Add table
Add a link
Reference in a new issue