mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix(Scripts): translate only if missing + handle '
This commit is contained in:
1 parent
aab0e2eb18
commit
7516aae2c1
1 file changed
+3
-2
@@ -34,7 +34,8 @@ async function translateText(text, targetLang) {
|
||||
key: GOOGLE_TRANSLATE_API_KEY,
|
||||
},
|
||||
});
|
||||
return response.data.data.translations[0].translatedText;
|
||||
return response.data.data.translations[0].translatedText
|
||||
.replace(/\{'/, '{\'').replace(/'\}/, '}\'');
|
||||
}
|
||||
|
||||
function flattenYaml(obj, prefix = '') {
|
||||
@@ -85,7 +86,7 @@ async function syncTranslations(englishFile, targetFiles, dryRun = false) {
|
||||
let langCharCount = 0;
|
||||
|
||||
for (const [key, englishText] of Object.entries(englishFlat)) {
|
||||
const needsTranslation = !targetFlat[key] || targetFlat[key] === englishText;
|
||||
const needsTranslation = !targetFlat[key];
|
||||
if (needsTranslation) {
|
||||
if (dryRun) {
|
||||
langCharCount += englishText.length;
|
||||
|
||||
Reference in new issue
Block a user