mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(i18n): Add Internationalization Support for UI and LLM Output (#1058)
This commit is contained in:
@@ -28,7 +28,7 @@ const targetDir = path.join('dist', 'src');
|
||||
|
||||
const extensionsToCopy = ['.md', '.json', '.sb'];
|
||||
|
||||
function copyFilesRecursive(source, target) {
|
||||
function copyFilesRecursive(source, target, rootSourceDir) {
|
||||
if (!fs.existsSync(target)) {
|
||||
fs.mkdirSync(target, { recursive: true });
|
||||
}
|
||||
@@ -40,9 +40,18 @@ function copyFilesRecursive(source, target) {
|
||||
const targetPath = path.join(target, item.name);
|
||||
|
||||
if (item.isDirectory()) {
|
||||
copyFilesRecursive(sourcePath, targetPath);
|
||||
} else if (extensionsToCopy.includes(path.extname(item.name))) {
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
copyFilesRecursive(sourcePath, targetPath, rootSourceDir);
|
||||
} else {
|
||||
const ext = path.extname(item.name);
|
||||
// Copy standard extensions, or .js files in i18n/locales directory
|
||||
// Use path.relative for precise matching to avoid false positives
|
||||
const relativePath = path.relative(rootSourceDir, sourcePath);
|
||||
const normalizedPath = relativePath.replace(/\\/g, '/');
|
||||
const isLocaleJs =
|
||||
ext === '.js' && normalizedPath.startsWith('i18n/locales/');
|
||||
if (extensionsToCopy.includes(ext) || isLocaleJs) {
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +61,7 @@ if (!fs.existsSync(sourceDir)) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
copyFilesRecursive(sourceDir, targetDir);
|
||||
copyFilesRecursive(sourceDir, targetDir, sourceDir);
|
||||
|
||||
// Copy example extensions into the bundle.
|
||||
const packageName = path.basename(process.cwd());
|
||||
|
||||
Reference in New Issue
Block a user