mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 14:48:51 +01:00
🌏 i18n: Added Missing Localizations (Ar, De, Es, Fr, It, Jp, Ko, Ru, Zh) (#4540)
* chore: remove comparisons * feat: use prompt caching for translations * chore: wip translation readme * i18n: korean translations * refactor: use promises for faster translation processing * refactor: update translation model to 'claude-3-5-sonnet-20241022' * refactor: optimize sleep duration for translation processing * i18n: add missing keys * refactor: standardize languages in their own respective languages * Refactor translation instructions in README.md
This commit is contained in:
parent
840851cb0f
commit
094a40dbb0
22 changed files with 3132 additions and 28864 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { processLanguageModule, processMissingKey } from './process';
|
||||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
export default async function main(baseFilePath: string, compareFilePath: string) {
|
||||
const prompt = await processLanguageModule(path.basename(compareFilePath), compareFilePath);
|
||||
|
|
@ -17,19 +18,30 @@ export default async function main(baseFilePath: string, compareFilePath: string
|
|||
const compareKeys = Object.keys(compareModule.default);
|
||||
|
||||
const missingKeys = baseKeys.filter((key) => !compareKeys.includes(key));
|
||||
const promises: Array<Promise<void>> = [];
|
||||
if (missingKeys.length > 0) {
|
||||
const keyTranslations = {};
|
||||
for (const key of missingKeys) {
|
||||
const baselineTranslation = baseModule.default[key] || 'No baseline translation available';
|
||||
const result = await processMissingKey({
|
||||
key,
|
||||
baselineTranslation,
|
||||
translationPrompt: prompt,
|
||||
moduleName: path.basename(compareFilePath),
|
||||
});
|
||||
keyTranslations[key] = result;
|
||||
const handleMissingKey = async () => {
|
||||
try {
|
||||
const result = await processMissingKey({
|
||||
key,
|
||||
baselineTranslation,
|
||||
translationPrompt: prompt,
|
||||
moduleName: path.basename(compareFilePath),
|
||||
});
|
||||
keyTranslations[key] = result;
|
||||
} catch (e) {
|
||||
console.error(`Error processing key: ${key}`, e);
|
||||
}
|
||||
};
|
||||
|
||||
promises.push(handleMissingKey());
|
||||
await sleep(700);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
const outputDir = path.dirname(compareFilePath);
|
||||
const outputFileName = `${path.basename(
|
||||
compareFilePath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue