Fix: i18n sync status

This commit is contained in:
eight 2019-10-30 01:54:26 +08:00
parent cd1f78e19e
commit 008ca33b16
3 changed files with 48 additions and 9 deletions

View File

@ -1027,6 +1027,43 @@
"optionsSyncLogin": { "optionsSyncLogin": {
"message": "Login" "message": "Login"
}, },
"optionsSyncStatusPull": {
"message": "Pulling style $loaded$ of $total$",
"placeholders": {
"loaded": {
"content": "$1"
},
"total": {
"content": "$2"
}
}
},
"optionsSyncStatusPush": {
"message": "Pushing style $loaded$ of $total$",
"placeholders": {
"loaded": {
"content": "$1"
},
"total": {
"content": "$2"
}
}
},
"optionsSyncStatusSyncing": {
"message": "Syncing..."
},
"optionsSyncStatusConnecting": {
"message": "Connecting..."
},
"optionsSyncStatusConnected": {
"message": "Connected"
},
"optionsSyncStatusDisconnecting": {
"message": "Disconnecting..."
},
"optionsSyncStatusDisconnected": {
"message": "Disconnected"
},
"paginationCurrent": { "paginationCurrent": {
"message": "Current page", "message": "Current page",
"description": "Tooltip for the current page index in search results" "description": "Tooltip for the current page index in search results"

View File

@ -1,6 +1,6 @@
/* exported getActiveTab onTabReady stringAsRegExp getTabRealURL openURL /* exported getActiveTab onTabReady stringAsRegExp getTabRealURL openURL
getStyleWithNoCode tryRegExp sessionStorageHash download getStyleWithNoCode tryRegExp sessionStorageHash download
closeCurrentTab */ closeCurrentTab capitalize */
'use strict'; 'use strict';
const CHROME = Boolean(chrome.app) && parseInt(navigator.userAgent.match(/Chrom\w+\/(?:\d+\.){2}(\d+)|$/)[1]); const CHROME = Boolean(chrome.app) && parseInt(navigator.userAgent.match(/Chrom\w+\/(?:\d+\.){2}(\d+)|$/)[1]);
@ -481,3 +481,7 @@ function closeCurrentTab() {
} }
}); });
} }
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}

View File

@ -1,6 +1,6 @@
/* global messageBox msg setupLivePrefs enforceInputRange /* global messageBox msg setupLivePrefs enforceInputRange
$ $$ $create $createLink $ $$ $create $createLink
FIREFOX OPERA CHROME URLS openURL prefs t API ignoreChromeError */ FIREFOX OPERA CHROME URLS openURL prefs t API ignoreChromeError capitalize */
'use strict'; 'use strict';
setupLivePrefs(); setupLivePrefs();
@ -121,17 +121,15 @@ document.onclick = e => {
if (status.syncing) { if (status.syncing) {
if (status.progress) { if (status.progress) {
const {phase, loaded, total} = status.progress; const {phase, loaded, total} = status.progress;
return `${phase}ing style ${loaded + 1} of ${total}`; return chrome.i18n.getMessage(`optionsSyncStatus${capitalize(phase)}`, [loaded + 1, total]) ||
`${phase} ${loaded} / ${total}`;
} }
return 'syncing...'; return chrome.i18n.getMessage('optionsSyncStatusSyncing') || 'syncing';
} }
if (status.state.endsWith('ing')) { if ((status.state === 'connected' || status.state === 'disconnected') && status.errorMessage) {
return status.state + '...';
}
if (status.errorMessage) {
return status.errorMessage; return status.errorMessage;
} }
return status.state; return chrome.i18n.getMessage(`optionsSyncStatus${capitalize(status.state)}`) || status.state;
} }
connectButton.addEventListener('click', e => { connectButton.addEventListener('click', e => {