fix: optimize translations

more direct string-concatenation, thanks to @lurch
This commit is contained in:
r-q 2022-07-21 23:44:07 +08:00 committed by Anton Belodedenko
parent 67d26ff790
commit eb5f5bbb9e
4 changed files with 41 additions and 27 deletions

View File

@ -33,13 +33,14 @@ const translation = {
flashFail_one: 'Failed target', flashFail_one: 'Failed target',
flashFail_other: 'Failed targets', flashFail_other: 'Failed targets',
to: 'to ', to: 'to ',
succeedTarget_one: 'to {{num}} target', toDrive: 'to {{description}} ({{name}})',
succeedTarget_other: 'to {{num}} targets', toTarget_one: 'to {{num}} target',
toTarget_other: 'to {{num}} targets',
andFailTarget_one: 'and failed to be flashed to {{num}} target', andFailTarget_one: 'and failed to be flashed to {{num}} target',
andFailTarget_other: 'and failed to be flashed to {{num}} targets', andFailTarget_other: 'and failed to be flashed to {{num}} targets',
target_one: ' target', target_one: ' target',
target_other: ' targets', target_other: ' targets',
succeedTo: 'was successfully flashed', succeedTo: '{{name}} was successfully flashed to {{target}}',
exitWhileFlashing: exitWhileFlashing:
'You are currently flashing a drive. Closing Etcher may leave your drive in an unusable state.', 'You are currently flashing a drive. Closing Etcher may leave your drive in an unusable state.',
looksLikeWindowsImage: looksLikeWindowsImage:
@ -56,12 +57,13 @@ const translation = {
noSpace: noSpace:
'Not enough space on the drive. Please insert larger one and try again.', 'Not enough space on the drive. Please insert larger one and try again.',
genericFlashError: 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: 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.', '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: openError:
'Something went wrong while opening {{source}}.\n\nError: {{error}}', '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: 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.", "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: cannotWrite:

View File

@ -33,13 +33,14 @@ const translation = {
flashFail_one: '烧录失败', flashFail_one: '烧录失败',
flashFail_other: '烧录失败', flashFail_other: '烧录失败',
to: '到 ', to: '到 ',
succeedTarget_one: '到 {{num}} 个目标', toDrive: '到 {{description}} ({{name}})',
succeedTarget_other: '到 {{num}} 个目标', toTarget_one: '到 {{num}} 个目标',
toTarget_other: '到 {{num}} 个目标',
andFailTarget_one: '并烧录失败了 {{num}} 个目标', andFailTarget_one: '并烧录失败了 {{num}} 个目标',
andFailTarget_other: '并烧录失败了 {{num}} 个目标', andFailTarget_other: '并烧录失败了 {{num}} 个目标',
target_one: ' 个目标', target_one: ' 个目标',
target_other: ' 个目标', target_other: ' 个目标',
succeedTo: '被成功烧录', succeedTo: '{{name}} 被成功烧录到 {{target}}',
exitWhileFlashing: exitWhileFlashing:
'您当前正在刷机。 关闭 Etcher 可能会导致您的磁盘无法使用。', '您当前正在刷机。 关闭 Etcher 可能会导致您的磁盘无法使用。',
looksLikeWindowsImage: looksLikeWindowsImage:
@ -53,11 +54,11 @@ const translation = {
sourceDrive: '源镜像位于这个分区中', sourceDrive: '源镜像位于这个分区中',
noSpace: '磁盘空间不足。 请插入另一个较大的磁盘并重试。', noSpace: '磁盘空间不足。 请插入另一个较大的磁盘并重试。',
genericFlashError: genericFlashError:
'出了点问题。如果源镜像曾被压缩过,请检查它是否已损坏。', '出了点问题。如果源镜像曾被压缩过,请检查它是否已损坏。\n{{error}}',
validation: validation:
'写入已成功完成,但 Etcher 在从磁盘读取镜像时检测到潜在的损坏问题。 \n\n请考虑将镜像写入其他磁盘。', '写入已成功完成,但 Etcher 在从磁盘读取镜像时检测到潜在的损坏问题。 \n\n请考虑将镜像写入其他磁盘。',
openError: '打开 {{source}} 时出错。\n\n错误信息 {{error}}', openError: '打开 {{source}} 时出错。\n\n错误信息 {{error}}',
flashError: '烧录 {{image}} 到 {{target}} 失败。', flashError: '烧录 {{image}} 到 {{targets}} 失败。',
unplug: unplug:
'看起来 Etcher 失去了对磁盘的连接。 它是不是被意外拔掉了?\n\n有时这个错误是因为读卡器出了故障。', '看起来 Etcher 失去了对磁盘的连接。 它是不是被意外拔掉了?\n\n有时这个错误是因为读卡器出了故障。',
cannotWrite: cannotWrite:

View File

@ -33,13 +33,14 @@ const translation = {
flashFail_one: '燒錄失敗', flashFail_one: '燒錄失敗',
flashFail_other: '燒錄失敗', flashFail_other: '燒錄失敗',
to: '到 ', to: '到 ',
succeedTarget_one: '到 {{num}} 個目標', toDrive: '到 {{description}} ({{name}})',
succeedTarget_other: '到 {{num}} 個目標', toTarget_one: '到 {{num}} 個目標',
toTarget_other: '到 {{num}} 個目標',
andFailTarget_one: '並燒錄失敗了 {{num}} 個目標', andFailTarget_one: '並燒錄失敗了 {{num}} 個目標',
andFailTarget_other: '並燒錄失敗了 {{num}} 個目標', andFailTarget_other: '並燒錄失敗了 {{num}} 個目標',
target_one: ' 個目標', target_one: ' 個目標',
target_other: ' 個目標', target_other: ' 個目標',
succeedTo: '被成功燒錄', succeedTo: '{{name}} 被成功燒錄到 {{target}}',
exitWhileFlashing: exitWhileFlashing:
'您當前正在刷機。 關閉 Etcher 可能會導致您的磁盤無法使用。', '您當前正在刷機。 關閉 Etcher 可能會導致您的磁盤無法使用。',
looksLikeWindowsImage: looksLikeWindowsImage:
@ -53,11 +54,11 @@ const translation = {
sourceDrive: '源鏡像位於這個分區中', sourceDrive: '源鏡像位於這個分區中',
noSpace: '磁盤空間不足。 請插入另一個較大的磁盤並重試。', noSpace: '磁盤空間不足。 請插入另一個較大的磁盤並重試。',
genericFlashError: genericFlashError:
'出了點問題。如果源鏡像曾被壓縮過,請檢查它是否已損壞。', '出了點問題。如果源鏡像曾被壓縮過,請檢查它是否已損壞。\n{{error}}',
validation: validation:
'寫入已成功完成,但 Etcher 在從磁盤讀取鏡像時檢測到潛在的損壞問題。 \n\n請考慮將鏡像寫入其他磁盤。', '寫入已成功完成,但 Etcher 在從磁盤讀取鏡像時檢測到潛在的損壞問題。 \n\n請考慮將鏡像寫入其他磁盤。',
openError: '打開 {{source}} 時出錯。\n\n錯誤信息 {{error}}', openError: '打開 {{source}} 時出錯。\n\n錯誤信息 {{error}}',
flashError: '燒錄 {{image}} 到 {{target}} 失敗。', flashError: '燒錄 {{image}} 到 {{targets}} 失敗。',
unplug: unplug:
'看起來 Etcher 失去了對磁盤的連接。 它是不是被意外拔掉了?\n\n有時這個錯誤是因爲讀卡器出了故障。', '看起來 Etcher 失去了對磁盤的連接。 它是不是被意外拔掉了?\n\n有時這個錯誤是因爲讀卡器出了故障。',
cannotWrite: cannotWrite:

View File

@ -39,12 +39,15 @@ export const info = {
const targets = []; const targets = [];
if (failed + successful === 1) { if (failed + successful === 1) {
targets.push( targets.push(
i18next.t('message.to') + `${drive.description} (${drive.displayName})`, i18next.t('message.toDrive', {
description: drive.description,
name: drive.displayName,
}),
); );
} else { } else {
if (successful) { if (successful) {
targets.push( targets.push(
i18next.t('message.succeedTarget', { i18next.t('message.toTarget', {
count: successful, count: successful,
num: successful, num: successful,
}), }),
@ -56,11 +59,10 @@ export const info = {
); );
} }
} }
return ( return i18next.t('message.succeedTo', {
`${imageBasename} ` + name: imageBasename,
i18next.t('message.succeedTo') + target: targets.join(' '),
` ${targets.join(' ')}` });
);
}, },
}; };
@ -135,7 +137,7 @@ export const error = {
}, },
genericFlashError: (err: Error) => { genericFlashError: (err: Error) => {
return i18next.t('message.genericFlashError') + `\n${err.message}`; return i18next.t('message.genericFlashError', { error: err.message });
}, },
validation: () => { validation: () => {
@ -155,10 +157,18 @@ export const error = {
) => { ) => {
const target = const target =
drives.length === 1 drives.length === 1
? `${drives[0].description} (${drives[0].displayName})` ? i18next.t('message.toDrive', {
: `${drives.length}` + description: drives[0].description,
i18next.t('message.target', { count: drives.length }); name: drives[0].displayName,
return i18next.t('message.flashError', { image: imageBasename, target }); })
: i18next.t('message.toTarget', {
count: drives.length,
num: drives.length,
});
return i18next.t('message.flashError', {
image: imageBasename,
targets: target,
});
}, },
driveUnplugged: () => { driveUnplugged: () => {