fix(Scripts): translate only if missing + handle '

This commit is contained in:
ShareVB committed 2025-10-19 16:45:18 +02:00
1 parent aab0e2eb18
commit 7516aae2c1
1 file changed
+3 -2
+3 -2
View File
@@ -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;