mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 10:50:14 +01:00
Feature Localization (i18n) Support (#557)
* init localization * Update defaul to en * Fix merge issue and import path. * Set default to en * Change jsx to tsx * Update the password max length string. * Remove languageContext as using the recoil instead.
This commit is contained in:
parent
13627c7f4f
commit
47e5493744
15 changed files with 29076 additions and 115 deletions
18
client/src/localization/Translation.tsx
Normal file
18
client/src/localization/Translation.tsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import English from './languages/Eng';
|
||||
import Chinese from './languages/Zh';
|
||||
// === import additional language files here === //
|
||||
|
||||
// input: language code in string
|
||||
// returns an object of translated strings in the language
|
||||
export const getTranslations = (langCode: string) => {
|
||||
if (langCode === 'en') return English;
|
||||
if (langCode === 'cn') return Chinese;
|
||||
// === add conditionals here for additional languages here === //
|
||||
};
|
||||
|
||||
// input: language code in string & phrase key in string
|
||||
// returns an corresponding phrase value in string
|
||||
export const localize = (langCode: string, phraseKey: string) => {
|
||||
const lang = getTranslations(langCode);
|
||||
return lang[phraseKey];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue