Skip to content

Commit 0507cc1

Browse files
authored
Update translation script + run translations (#184)
* Remove old entries * Run translations
1 parent 8788c8f commit 0507cc1

File tree

5 files changed

+150
-25
lines changed

5 files changed

+150
-25
lines changed

renderer/intl/locales/es-MX.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@
527527
"message": "Crear",
528528
"description": "Create"
529529
},
530-
"WHjylD": {
531-
"message": "Por favor, reinicia la aplicación y vuelve a intentarlo. Si el problema persiste, déjanos saber en Discord para que podamos ayudarte a solucionarlo.",
532-
"description": "Please restart the app and try again. If the issue persists, let us know on Discord so we can help troubleshoot."
533-
},
534530
"WKCp0D": {
535531
"message": "Activo",
536532
"description": "Asset"
@@ -922,5 +918,33 @@
922918
"zl76y/": {
923919
"message": "El texto debe coincidir con el nombre de la cuenta ''{accountName}''",
924920
"description": "Text must match the account name ''{accountName}''"
921+
},
922+
"6Zll8z": {
923+
"message": "Reinicia el nodo. Tendrás que volver a escanear la cadena de bloques, pero tus cuentas y fondos no se verán afectados.",
924+
"description": "Reset the node. You'll have to re-scan the blockchain, but your accounts and funds will not be affected."
925+
},
926+
"IwW0RC": {
927+
"message": "Si ninguno de estos pasos ayuda, por favor reporta el problema en <link>Discord</link>.",
928+
"description": "If none of these steps help, please report the issue on <link>Discord</link>."
929+
},
930+
"KGELcL": {
931+
"message": "Cambio",
932+
"description": "Change"
933+
},
934+
"KiaI4a": {
935+
"message": "Intenta reiniciar la aplicación",
936+
"description": "Try restarting the app"
937+
},
938+
"bqjW+S": {
939+
"message": "Pasos de solución de problemas",
940+
"description": "Troubleshooting Steps"
941+
},
942+
"kNJdlj": {
943+
"message": "Reinicia la aplicación",
944+
"description": "Restart App"
945+
},
946+
"oZO6n5": {
947+
"message": "Una actualización de la aplicación está disponible. Espera a que termine de descargarse y reinicia la aplicación, o descarga la última versión de la <link> página web de Iron Fish </link>.",
948+
"description": "An app update is available. Wait for it to finish downloading and restart the app, or download the latest version from the <link>Iron Fish website</link>."
925949
}
926950
}

renderer/intl/locales/ru-RU.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@
527527
"message": "Создать",
528528
"description": "Create"
529529
},
530-
"WHjylD": {
531-
"message": "Пожалуйста, перезапустите приложение и попробуйте снова. Если проблема сохраняется, сообщите нам на Discord, чтобы мы могли помочь в устранении неполадок.",
532-
"description": "Please restart the app and try again. If the issue persists, let us know on Discord so we can help troubleshoot."
533-
},
534530
"WKCp0D": {
535531
"message": "Актив",
536532
"description": "Asset"
@@ -922,5 +918,33 @@
922918
"zl76y/": {
923919
"message": "Текст должен соответствовать имени учетной записи ''{accountName}''",
924920
"description": "Text must match the account name ''{accountName}''"
921+
},
922+
"6Zll8z": {
923+
"message": "Сбросьте узел. Вам придется заново сканировать блокчейн, но это не повлияет на ваши аккаунты и средства.",
924+
"description": "Reset the node. You'll have to re-scan the blockchain, but your accounts and funds will not be affected."
925+
},
926+
"IwW0RC": {
927+
"message": "Если ни один из этих шагов не помог, пожалуйста, сообщите об этой проблеме в <link>Discord</link>.",
928+
"description": "If none of these steps help, please report the issue on <link>Discord</link>."
929+
},
930+
"KGELcL": {
931+
"message": "Сдача",
932+
"description": "Change"
933+
},
934+
"KiaI4a": {
935+
"message": "Попробуйте перезапустить приложение",
936+
"description": "Try restarting the app"
937+
},
938+
"bqjW+S": {
939+
"message": "Шаги по устранению неполадок",
940+
"description": "Troubleshooting Steps"
941+
},
942+
"kNJdlj": {
943+
"message": "Перезапустить приложение",
944+
"description": "Restart App"
945+
},
946+
"oZO6n5": {
947+
"message": "Доступно обновление приложения. Дождитесь его загрузки и перезапустите приложение, или скачайте последнюю версию с <link>сайта Iron Fish</link>.",
948+
"description": "An app update is available. Wait for it to finish downloading and restart the app, or download the latest version from the <link>Iron Fish website</link>."
925949
}
926950
}

renderer/intl/locales/uk-UA.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@
527527
"message": "Створити",
528528
"description": "Create"
529529
},
530-
"WHjylD": {
531-
"message": "Будь ласка, перезапустіть додаток та спробуйте знову. Якщо проблема збережеться, повідомте нам в Discord, щоб ми могли допомогти у вирішенні проблеми.",
532-
"description": "Please restart the app and try again. If the issue persists, let us know on Discord so we can help troubleshoot."
533-
},
534530
"WKCp0D": {
535531
"message": "Актив",
536532
"description": "Asset"
@@ -922,5 +918,33 @@
922918
"zl76y/": {
923919
"message": "Текст повинен відповідати назві облікового запису ''{accountName}''",
924920
"description": "Text must match the account name ''{accountName}''"
921+
},
922+
"6Zll8z": {
923+
"message": "Скиньте вузол. Вам доведеться повторно відсканувати блокчейн, але ваші аккаунти та кошти не будуть зачеплені.",
924+
"description": "Reset the node. You'll have to re-scan the blockchain, but your accounts and funds will not be affected."
925+
},
926+
"IwW0RC": {
927+
"message": "Якщо жоден з цих кроків не допоміг, будь ласка, повідомте про проблему на <link>Discord</link>.",
928+
"description": "If none of these steps help, please report the issue on <link>Discord</link>."
929+
},
930+
"KGELcL": {
931+
"message": "Решта",
932+
"description": "Change"
933+
},
934+
"KiaI4a": {
935+
"message": "Спробуйте перезапустити додаток",
936+
"description": "Try restarting the app"
937+
},
938+
"bqjW+S": {
939+
"message": "Кроки для усунення неполадок",
940+
"description": "Troubleshooting Steps"
941+
},
942+
"kNJdlj": {
943+
"message": "Перезапустити додаток",
944+
"description": "Restart App"
945+
},
946+
"oZO6n5": {
947+
"message": "Доступне оновлення додатка. Зачекайте, поки воно завантажиться, і перезапустіть додаток, або завантажте останню версію з <link>веб-сайту Iron Fish</link>.",
948+
"description": "An app update is available. Wait for it to finish downloading and restart the app, or download the latest version from the <link>Iron Fish website</link>."
925949
}
926950
}

renderer/intl/locales/zh-CN.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@
527527
"message": "创建",
528528
"description": "Create"
529529
},
530-
"WHjylD": {
531-
"message": "请重启应用并重试。如果问题仍然存在,请在Discord上告诉我们,我们可以帮助您解决问题。",
532-
"description": "Please restart the app and try again. If the issue persists, let us know on Discord so we can help troubleshoot."
533-
},
534530
"WKCp0D": {
535531
"message": "资产",
536532
"description": "Asset"
@@ -922,5 +918,33 @@
922918
"zl76y/": {
923919
"message": "文本必须与帐户名称''{accountName}''匹配",
924920
"description": "Text must match the account name ''{accountName}''"
921+
},
922+
"6Zll8z": {
923+
"message": "重置节点。您将需要重新扫描区块链,但您的帐户和资金不会受到影响。",
924+
"description": "Reset the node. You'll have to re-scan the blockchain, but your accounts and funds will not be affected."
925+
},
926+
"IwW0RC": {
927+
"message": "如果这些步骤都无效,请在<link>Discord</link>上报告问题。",
928+
"description": "If none of these steps help, please report the issue on <link>Discord</link>."
929+
},
930+
"KGELcL": {
931+
"message": "零钱",
932+
"description": "Change"
933+
},
934+
"KiaI4a": {
935+
"message": "尝试重启应用",
936+
"description": "Try restarting the app"
937+
},
938+
"bqjW+S": {
939+
"message": "故障排除步骤",
940+
"description": "Troubleshooting Steps"
941+
},
942+
"kNJdlj": {
943+
"message": "重启应用",
944+
"description": "Restart App"
945+
},
946+
"oZO6n5": {
947+
"message": "应用有更新。等待其完成下载并重启应用,或从<link>Iron Fish 网站</link>下载最新版本。",
948+
"description": "An app update is available. Wait for it to finish downloading and restart the app, or download the latest version from the <link>Iron Fish website</link>."
925949
}
926950
}

scripts/openai-translator.ts

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,23 @@ async function translate(content: JSONContent, targetLanguage: string) {
111111
}
112112
}
113113

114-
function createContentChunks(content: JSONContent) {
115-
const entries = Object.entries(content);
114+
function createContentChunks(
115+
englishContent: JSONContent,
116+
localeContent: JSONContent,
117+
) {
118+
const missingContent: JSONContent = {};
119+
120+
for (const [key, value] of Object.entries(englishContent)) {
121+
const needsTranslation =
122+
!Object.hasOwn(localeContent, key) ||
123+
localeContent[key].description !== englishContent[key].message;
124+
125+
if (needsTranslation) {
126+
missingContent[key] = value;
127+
}
128+
}
129+
130+
const entries = Object.entries(missingContent);
116131
const chunks: JSONContent[] = [];
117132
let currentChunk: JSONContent = {};
118133

@@ -168,7 +183,9 @@ function assertLocale(str: string): asserts str is (typeof LOCALES)[number] {
168183
// Translate a specific locales:
169184
// npm run translate -- --locale=es-MX
170185
async function main() {
171-
let locales: ReadonlyArray<Locale> = LOCALES;
186+
let locales: ReadonlyArray<Locale> = LOCALES.filter(
187+
(locale) => locale !== "en-US",
188+
);
172189

173190
const args = process.argv.slice(2);
174191
const specifiedLocale = args.find((arg) => arg.startsWith("--locale="));
@@ -181,15 +198,27 @@ async function main() {
181198

182199
console.log(`Translating the following locales: ${locales.join(", ")}\n`);
183200

184-
// Chunk out content to prevent hitting the token limit.
185-
// Note that the limit is currently far below the actual limit.
186-
const englishChunks = createContentChunks(english);
187-
188201
// Translate each language and write result to file
189202
for (const locale of locales) {
190203
console.log(`Starting translation for locale: ${locale}\n`);
191-
let translatedContent = {};
192204

205+
// Get existing translated content. We'll only translate missing content.
206+
const localeFilePath = path.join(
207+
__dirname,
208+
`../renderer/intl/locales/${locale}.json`,
209+
);
210+
let currentTranslation: JSONContent = {};
211+
212+
if (fs.existsSync(localeFilePath)) {
213+
currentTranslation = JSON.parse(fs.readFileSync(localeFilePath, "utf-8"));
214+
}
215+
216+
// Chunk out content to prevent hitting the token limit.
217+
// Note that the limit is currently far below the actual limit.
218+
// This function also diffs the content to only translate missing entries.
219+
const englishChunks = createContentChunks(english, currentTranslation);
220+
221+
let translatedContent = currentTranslation;
193222
let currentChunk = 0;
194223

195224
for await (const chunk of englishChunks) {
@@ -215,7 +244,7 @@ async function main() {
215244
console.log(`Writing translation to ${locale}.json`);
216245

217246
fs.writeFileSync(
218-
path.join(__dirname, `../renderer/intl/locales/${locale}.json`),
247+
localeFilePath,
219248
JSON.stringify(translatedContent, null, 2),
220249
);
221250
}

0 commit comments

Comments
 (0)