Fix/23066 i18n related commands are broken (#23071)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
crazywoola
2025-07-28 21:25:18 +08:00
committed by GitHub
parent 572a2bbe53
commit 5f550126b3
6 changed files with 8 additions and 204 deletions

View File

@@ -8,6 +8,7 @@ const { translate } = bingTranslate
const data = require('./languages.json')
const targetLanguage = 'en-US'
const i18nFolder = '../i18n' // Path to i18n folder relative to this script
// https://github.com/plainheart/bing-translate-api/blob/master/src/met/lang.json
const languageKeyMap = data.languages.reduce((map, language) => {
if (language.supported) {
@@ -52,10 +53,9 @@ async function translateMissingKeyDeeply(sourceObj, targetObject, toLanguage) {
}
}))
}
async function autoGenTrans(fileName, toGenLanguage) {
const fullKeyFilePath = path.join(__dirname, targetLanguage, `${fileName}.ts`)
const toGenLanguageFilePath = path.join(__dirname, toGenLanguage, `${fileName}.ts`)
const fullKeyFilePath = path.join(__dirname, i18nFolder, targetLanguage, `${fileName}.ts`)
const toGenLanguageFilePath = path.join(__dirname, i18nFolder, 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
@@ -87,9 +87,8 @@ async function main() {
// Promise.all(Object.keys(languageKeyMap).map(async (toLanguage) => {
// await autoGenTrans(fileName, toLanguage)
// }))
const files = fs
.readdirSync(path.join(__dirname, targetLanguage))
.readdirSync(path.join(__dirname, i18nFolder, targetLanguage))
.map(file => file.replace(/\.ts/, ''))
.filter(f => f !== 'app-debug') // ast parse error in app-debug

View File

@@ -8,7 +8,7 @@ const languages = data.languages.filter(language => language.supported).map(lang
async function getKeysFromLanuage(language) {
return new Promise((resolve, reject) => {
const folderPath = path.join(__dirname, language)
const folderPath = path.join(__dirname, '../i18n', language)
let allKeys = []
fs.readdir(folderPath, (err, files) => {
if (err) {