From eb5f5bbb9e6f679914d552f98583de45e0f57519 Mon Sep 17 00:00:00 2001 From: r-q Date: Thu, 21 Jul 2022 23:44:07 +0800 Subject: [PATCH] fix: optimize translations more direct string-concatenation, thanks to @lurch --- lib/gui/app/i18n/en.ts | 12 +++++++----- lib/gui/app/i18n/zh-CN.ts | 11 ++++++----- lib/gui/app/i18n/zh-TW.ts | 11 ++++++----- lib/shared/messages.ts | 34 ++++++++++++++++++++++------------ 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/lib/gui/app/i18n/en.ts b/lib/gui/app/i18n/en.ts index a201d4ef..aaeb2631 100644 --- a/lib/gui/app/i18n/en.ts +++ b/lib/gui/app/i18n/en.ts @@ -33,13 +33,14 @@ const translation = { flashFail_one: 'Failed target', flashFail_other: 'Failed targets', to: 'to ', - succeedTarget_one: 'to {{num}} target', - succeedTarget_other: 'to {{num}} targets', + toDrive: 'to {{description}} ({{name}})', + toTarget_one: 'to {{num}} target', + toTarget_other: 'to {{num}} targets', andFailTarget_one: 'and failed to be flashed to {{num}} target', andFailTarget_other: 'and failed to be flashed to {{num}} targets', target_one: ' target', target_other: ' targets', - succeedTo: 'was successfully flashed', + succeedTo: '{{name}} was successfully flashed to {{target}}', exitWhileFlashing: 'You are currently flashing a drive. Closing Etcher may leave your drive in an unusable state.', looksLikeWindowsImage: @@ -56,12 +57,13 @@ const translation = { noSpace: 'Not enough space on the drive. Please insert larger one and try again.', genericFlashError: - 'Something went wrong. If it is a compressed image, please check that the archive is not corrupted.', + 'Something went wrong. If it is a compressed image, please check that the archive is not corrupted.\n{{error}}', validation: 'The write has been completed successfully but Etcher detected potential corruption issues when reading the image back from the drive. \n\nPlease consider writing the image to a different drive.', openError: 'Something went wrong while opening {{source}}.\n\nError: {{error}}', - flashError: 'Something went wrong while writing {{image}} to {{target}}.', + flashError: + 'Something went wrong while writing {{image}} to {{targets}}.', unplug: "Looks like Etcher lost access to the drive. Did it get unplugged accidentally?\n\nSometimes this error is caused by faulty readers that don't provide stable access to the drive.", cannotWrite: diff --git a/lib/gui/app/i18n/zh-CN.ts b/lib/gui/app/i18n/zh-CN.ts index 2df35d8b..7a370359 100644 --- a/lib/gui/app/i18n/zh-CN.ts +++ b/lib/gui/app/i18n/zh-CN.ts @@ -33,13 +33,14 @@ const translation = { flashFail_one: '烧录失败', flashFail_other: '烧录失败', to: '到 ', - succeedTarget_one: '到 {{num}} 个目标', - succeedTarget_other: '到 {{num}} 个目标', + toDrive: '到 {{description}} ({{name}})', + toTarget_one: '到 {{num}} 个目标', + toTarget_other: '到 {{num}} 个目标', andFailTarget_one: '并烧录失败了 {{num}} 个目标', andFailTarget_other: '并烧录失败了 {{num}} 个目标', target_one: ' 个目标', target_other: ' 个目标', - succeedTo: '被成功烧录', + succeedTo: '{{name}} 被成功烧录到 {{target}}', exitWhileFlashing: '您当前正在刷机。 关闭 Etcher 可能会导致您的磁盘无法使用。', looksLikeWindowsImage: @@ -53,11 +54,11 @@ const translation = { sourceDrive: '源镜像位于这个分区中', noSpace: '磁盘空间不足。 请插入另一个较大的磁盘并重试。', genericFlashError: - '出了点问题。如果源镜像曾被压缩过,请检查它是否已损坏。', + '出了点问题。如果源镜像曾被压缩过,请检查它是否已损坏。\n{{error}}', validation: '写入已成功完成,但 Etcher 在从磁盘读取镜像时检测到潜在的损坏问题。 \n\n请考虑将镜像写入其他磁盘。', openError: '打开 {{source}} 时出错。\n\n错误信息: {{error}}', - flashError: '烧录 {{image}} 到 {{target}} 失败。', + flashError: '烧录 {{image}} 到 {{targets}} 失败。', unplug: '看起来 Etcher 失去了对磁盘的连接。 它是不是被意外拔掉了?\n\n有时这个错误是因为读卡器出了故障。', cannotWrite: diff --git a/lib/gui/app/i18n/zh-TW.ts b/lib/gui/app/i18n/zh-TW.ts index 87592aca..3ad8be83 100644 --- a/lib/gui/app/i18n/zh-TW.ts +++ b/lib/gui/app/i18n/zh-TW.ts @@ -33,13 +33,14 @@ const translation = { flashFail_one: '燒錄失敗', flashFail_other: '燒錄失敗', to: '到 ', - succeedTarget_one: '到 {{num}} 個目標', - succeedTarget_other: '到 {{num}} 個目標', + toDrive: '到 {{description}} ({{name}})', + toTarget_one: '到 {{num}} 個目標', + toTarget_other: '到 {{num}} 個目標', andFailTarget_one: '並燒錄失敗了 {{num}} 個目標', andFailTarget_other: '並燒錄失敗了 {{num}} 個目標', target_one: ' 個目標', target_other: ' 個目標', - succeedTo: '被成功燒錄', + succeedTo: '{{name}} 被成功燒錄到 {{target}}', exitWhileFlashing: '您當前正在刷機。 關閉 Etcher 可能會導致您的磁盤無法使用。', looksLikeWindowsImage: @@ -53,11 +54,11 @@ const translation = { sourceDrive: '源鏡像位於這個分區中', noSpace: '磁盤空間不足。 請插入另一個較大的磁盤並重試。', genericFlashError: - '出了點問題。如果源鏡像曾被壓縮過,請檢查它是否已損壞。', + '出了點問題。如果源鏡像曾被壓縮過,請檢查它是否已損壞。\n{{error}}', validation: '寫入已成功完成,但 Etcher 在從磁盤讀取鏡像時檢測到潛在的損壞問題。 \n\n請考慮將鏡像寫入其他磁盤。', openError: '打開 {{source}} 時出錯。\n\n錯誤信息: {{error}}', - flashError: '燒錄 {{image}} 到 {{target}} 失敗。', + flashError: '燒錄 {{image}} 到 {{targets}} 失敗。', unplug: '看起來 Etcher 失去了對磁盤的連接。 它是不是被意外拔掉了?\n\n有時這個錯誤是因爲讀卡器出了故障。', cannotWrite: diff --git a/lib/shared/messages.ts b/lib/shared/messages.ts index cf60aac7..8f9e4a41 100644 --- a/lib/shared/messages.ts +++ b/lib/shared/messages.ts @@ -39,12 +39,15 @@ export const info = { const targets = []; if (failed + successful === 1) { targets.push( - i18next.t('message.to') + `${drive.description} (${drive.displayName})`, + i18next.t('message.toDrive', { + description: drive.description, + name: drive.displayName, + }), ); } else { if (successful) { targets.push( - i18next.t('message.succeedTarget', { + i18next.t('message.toTarget', { count: successful, num: successful, }), @@ -56,11 +59,10 @@ export const info = { ); } } - return ( - `${imageBasename} ` + - i18next.t('message.succeedTo') + - ` ${targets.join(' ')}` - ); + return i18next.t('message.succeedTo', { + name: imageBasename, + target: targets.join(' '), + }); }, }; @@ -135,7 +137,7 @@ export const error = { }, genericFlashError: (err: Error) => { - return i18next.t('message.genericFlashError') + `\n${err.message}`; + return i18next.t('message.genericFlashError', { error: err.message }); }, validation: () => { @@ -155,10 +157,18 @@ export const error = { ) => { const target = drives.length === 1 - ? `${drives[0].description} (${drives[0].displayName})` - : `${drives.length}` + - i18next.t('message.target', { count: drives.length }); - return i18next.t('message.flashError', { image: imageBasename, target }); + ? i18next.t('message.toDrive', { + description: drives[0].description, + name: drives[0].displayName, + }) + : i18next.t('message.toTarget', { + count: drives.length, + num: drives.length, + }); + return i18next.t('message.flashError', { + image: imageBasename, + targets: target, + }); }, driveUnplugged: () => {