feat(i18n): Add Internationalization Support for UI and LLM Output (#1058)

This commit is contained in:
pomelo
2025-11-21 15:44:37 +08:00
committed by GitHub
parent 640f30655d
commit 48b77541c3
98 changed files with 4740 additions and 636 deletions

View File

@@ -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());