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_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:

View File

@ -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:

View File

@ -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:

View File

@ -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: () => {