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
|
|
@ -27,9 +27,14 @@ async function getKeysFromLanuage(language) {
|
|||
// console.log(camelCaseFileName)
|
||||
const content = fs.readFileSync(filePath, 'utf8')
|
||||
// eslint-disable-next-line sonarjs/code-eval
|
||||
const translation = eval(transpile(content))
|
||||
const translationObj = eval(transpile(content))
|
||||
// console.log(translation)
|
||||
const keys = Object.keys(translation)
|
||||
if(!translationObj || typeof translationObj !== 'object') {
|
||||
console.error(`Error parsing file: ${filePath}`)
|
||||
reject(new Error(`Error parsing file: ${filePath}`))
|
||||
return
|
||||
}
|
||||
const keys = Object.keys(translationObj)
|
||||
const nestedKeys = []
|
||||
const iterateKeys = (obj, prefix = '') => {
|
||||
for (const key in obj) {
|
||||
|
|
@ -39,7 +44,7 @@ async function getKeysFromLanuage(language) {
|
|||
iterateKeys(obj[key], nestedKey)
|
||||
}
|
||||
}
|
||||
iterateKeys(translation)
|
||||
iterateKeys(translationObj)
|
||||
|
||||
allKeys = [...keys, ...nestedKeys].map(
|
||||
key => `${camelCaseFileName}.${key}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue