fix: auto translate failed when there is a new file in english (#19671)
This commit is contained in:
parent
1b4fea1794
commit
1c91736a6d
237 changed files with 7543 additions and 23 deletions
|
|
@ -43,7 +43,7 @@ async function translateMissingKeyDeeply(sourceObj, targetObject, toLanguage) {
|
|||
targetObject[key] = translation
|
||||
}
|
||||
catch {
|
||||
console.error(`Error translating ${sourceObj[key]}(${key}) to ${toLanguage}`)
|
||||
console.error(`Error translating "${sourceObj[key]}" to ${toLanguage}. Key: ${key}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,6 +59,14 @@ async function autoGenTrans(fileName, toGenLanguage) {
|
|||
const toGenLanguageFilePath = path.join(__dirname, toGenLanguage, `${fileName}.ts`)
|
||||
// eslint-disable-next-line sonarjs/code-eval
|
||||
const fullKeyContent = eval(transpile(fs.readFileSync(fullKeyFilePath, 'utf8')))
|
||||
// if toGenLanguageFilePath is not exist, create it
|
||||
if (!fs.existsSync(toGenLanguageFilePath)) {
|
||||
fs.writeFileSync(toGenLanguageFilePath, `const translation = {
|
||||
}
|
||||
|
||||
export default translation
|
||||
`)
|
||||
}
|
||||
// To keep object format and format it for magicast to work: const translation = { ... } => export default {...}
|
||||
const readContent = await loadFile(toGenLanguageFilePath)
|
||||
const { code: toGenContent } = generateCode(readContent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue