mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-10 10:02:36 +01:00
* chore: bun scripts * feat: comparisons * refactor: move scripts to own folder * feat: generated prompts script and Es output * feat: generated prompts * created prompts * feat: Russian localization prompts * translation setup * additional ES translations * additional ES translations * translation services * feat: additional translations * fix regex for parseParamPrompt * RU translations * remove stores from git * update gitignore * update gitignore * ZH translations * move gen prompt output location * ZH traditional translations * AR translations * chore: rename * JP * cleanup scripts * add additional instruction prompts * fix translation prompt and add DE * FR translations (rate limited so not complete) * chore: update translation comparisons * chore: remove unused AnthropicClient changes * refactor: use compositional styling for archive/delete buttons, fix manage archive table styling
72 lines
No EOL
2.9 KiB
TypeScript
72 lines
No EOL
2.9 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { exec } from 'child_process';
|
|
|
|
async function main(baseFilePath: string, languagesDir: string) {
|
|
const { default: baseLanguage } = await import(path.resolve(baseFilePath));
|
|
const files = fs.readdirSync(languagesDir);
|
|
|
|
for (let file of files) {
|
|
const ext = path.extname(file);
|
|
if (ext !== '.ts' && ext !== '.tsx') continue; // Only process TypeScript files
|
|
|
|
const filePath = path.resolve(languagesDir, file);
|
|
if (filePath === baseFilePath) continue; // Skip the base language file
|
|
|
|
const { default: otherLanguage } = await import(filePath);
|
|
let comparisons = {};
|
|
|
|
for (let key in otherLanguage) {
|
|
if (otherLanguage.hasOwnProperty(key) && baseLanguage.hasOwnProperty(key)) {
|
|
comparisons[key] = {
|
|
english: baseLanguage[key],
|
|
translated: otherLanguage[key]
|
|
};
|
|
}
|
|
}
|
|
|
|
let fileContent = fs.readFileSync(filePath, 'utf8');
|
|
const comparisonsObjRegex = /export const comparisons = {[\s\S]*?};/gm;
|
|
const hasComparisons = comparisonsObjRegex.test(fileContent);
|
|
const comparisonsExport = `\nexport const comparisons = ${JSON.stringify(comparisons, null, 2)};\n`;
|
|
|
|
if (hasComparisons) {
|
|
fileContent = fileContent.replace(comparisonsObjRegex, comparisonsExport);
|
|
} else {
|
|
fileContent = fileContent.trim() + comparisonsExport;
|
|
}
|
|
|
|
fs.writeFileSync(filePath, fileContent); // Write updated content back to file
|
|
}
|
|
|
|
// Execute ESLint with the --fix option on the entire directory
|
|
exec(`bunx eslint "${languagesDir}" --fix`, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.error('Error executing ESLint:', error);
|
|
return;
|
|
}
|
|
if (stderr) {
|
|
console.error('ESLint stderr:', stderr);
|
|
return;
|
|
}
|
|
console.log('ESLint stdout:', stdout);
|
|
});
|
|
}
|
|
|
|
const languagesDir = './client/src/localization/languages';
|
|
const baseFilePath = path.resolve(languagesDir, 'Eng.ts');
|
|
|
|
main(baseFilePath, languagesDir).catch(console.error);
|
|
|
|
|
|
// const prompt = `
|
|
|
|
// Write a prompt that is mindful of the nuances in the language with respect to its English counterpart, which serves as the baseline for translations. Here are the comparisons between the language translations and their English counterparts:
|
|
|
|
// ${comparisons}
|
|
|
|
|
|
// Please consider the above comparisons to enhance understanding and guide improvements in translations. Provide insights or suggestions that could help refine the translation process, focusing on cultural and contextual relevance.
|
|
|
|
// Please craft a prompt that can be used to better inform future translations to this language. Write this prompt in the translated language, with all its nuances detected, not in the English.
|
|
// `;
|