From e6f2034e644313ee088d821c72b0b4f0407039a6 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 13 Apr 2017 14:51:43 +0300 Subject: [PATCH] make import report messages localizable --- _locales/en/messages.json | 40 +++++++++++++++++++++++++++++++++++++++ backup/fileSaveLoad.js | 22 ++++++++++----------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index cb690d9e..9354a899 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -234,6 +234,46 @@ "message": "Type a command name", "description": "Placeholder text of inputbox in keymap help popup on the edit style page. Must be very short" }, + "importReportLegendAdded": { + "message": "added", + "description": "Text after the number of styles added in the report shown after importing styles" + }, + "importReportLegendIdentical": { + "message": "identical skipped", + "description": "Text after the number of styles skipped due to being identical to the already installed ones in the report shown after importing styles" + }, + "importReportLegendInvalid": { + "message": "invalid skipped", + "description": "Text after the number of styles skipped due to being invalid (not a Stylus/Stylish backup file probably) in the report shown after importing styles" + }, + "importReportLegendUpdatedBoth": { + "message": "updated both meta info and code", + "description": "Text after the number of styles updated entirely in the report shown after importing styles" + }, + "importReportLegendUpdatedCode": { + "message": "updated code", + "description": "Text after the number of styles with updated code (meta info is unchanged) in the report shown after importing styles" + }, + "importReportLegendUpdatedMeta": { + "message": "updated meta info", + "description": "Text after the number of styles with updated meta info like name/url in the report shown after importing styles" + }, + "importReportTitle": { + "message": "Finished importing styles", + "description": "Title of the report shown after importing styles" + }, + "importReportUnchanged": { + "message": "Nothing was changed.", + "description": "Message in the report shown after importing styles" + }, + "importReportUndoneTitle": { + "message": "Import has been undone", + "description": "Title of the message box shown after undoing the import of styles" + }, + "importReportUndone": { + "message": "styles were reverted", + "description": "Text after the number of styles reverted in the message box shown after undoing the import of styles" + }, "importLabel": { "message": "Import", "description": "Label for the button to import a style ('edit' page) or all styles ('manage' page)" diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index f451c674..466c5aa9 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -59,12 +59,12 @@ function importFromString(jsonString) { const oldStylesByName = json.length && new Map( oldStyles.map(style => [style.name.trim(), style])); const stats = { - added: {names: [], ids: [], legend: 'added'}, - unchanged: {names: [], ids: [], legend: 'identical skipped'}, - metaAndCode: {names: [], ids: [], legend: 'updated both meta info and code'}, - metaOnly: {names: [], ids: [], legend: 'updated meta info'}, - codeOnly: {names: [], ids: [], legend: 'updated code'}, - invalid: {names: [], legend: 'invalid skipped'}, + added: {names: [], ids: [], legend: 'importReportLegendAdded'}, + unchanged: {names: [], ids: [], legend: 'importReportLegendIdentical'}, + metaAndCode: {names: [], ids: [], legend: 'importReportLegendUpdatedBoth'}, + metaOnly: {names: [], ids: [], legend: 'importReportLegendUpdatedMeta'}, + codeOnly: {names: [], ids: [], legend: 'importReportLegendUpdatedCode'}, + invalid: {names: [], legend: 'importReportLegendInvalid'}, }; let index = 0; let lastRenderTime = performance.now(); @@ -153,14 +153,14 @@ function importFromString(jsonString) { .filter(kind => stats[kind].names.length) .map(kind => `
- ${stats[kind].names.length} ${stats[kind].legend} + ${stats[kind].names.length} ${t(stats[kind].legend)} ${listNames(kind).join('')}
`) .join(''); scrollTo(0, 0); messageBox({ - title: 'Finished importing styles', - contents: report || 'Nothing was changed.', + title: t('importReportTitle'), + contents: report || t('importReportUnchanged'), buttons: [t('confirmOK'), numChanged && t('undo')], onshow: bindClick, }).then(({button, enter, esc}) => { @@ -184,8 +184,8 @@ function importFromString(jsonString) { return new Promise(undoNextId) .then(BG.refreshAllTabs) .then(() => messageBox({ - title: 'Import has been undone', - contents: newIds.length + ' styles were reverted.', + title: t('importReportUndoneTitle'), + contents: newIds.length + ' ' + t('importReportUndone'), buttons: [t('confirmOK')], })); function undoNextId(resolve) {