#1163 i18n improvement

This commit is contained in:
Grzegorz Zając 2023-06-21 10:15:03 +02:00
parent b8616b81b7
commit 0dae7e0bdd
3 changed files with 52 additions and 51 deletions

View File

@ -6,7 +6,7 @@
2 - onTabRemoved
3 - onTabUpdated
4 - browserAction
5 - initPluginAction
5 - initBEAction
6 - updateBrowserInfo
7 - handleConfigurationRequest
8 - handleLoginRequest

View File

@ -18,6 +18,7 @@
//
const browser = require('webextension-polyfill');
const t = require('./_locales/en/notifications.json');
const config = {
WebSocketTimeout: 3, // in minutes
@ -27,107 +28,107 @@ const config = {
Texts: {
Error: {
General: {
Title: browser.i18n.getMessage('errorGeneralTitle'),
Message: browser.i18n.getMessage('errorGeneralMessage')
Title: browser.i18n.getMessage('errorGeneralTitle') || t.errorGeneralTitle,
Message: browser.i18n.getMessage('errorGeneralMessage') || t.errorGeneralMessage
},
UndefinedError: {
Title: browser.i18n.getMessage('errorUndefinedErrorTitle'),
Message: browser.i18n.getMessage('errorUndefinedErrorMessage')
Title: browser.i18n.getMessage('errorUndefinedErrorTitle') || t.errorUndefinedErrorTitle,
Message: browser.i18n.getMessage('errorUndefinedErrorMessage') || t.errorUndefinedErrorMessage
},
Timeout: {
Title: browser.i18n.getMessage('errorTimeoutTitle'),
Message: browser.i18n.getMessage('errorTimeoutMessage')
Title: browser.i18n.getMessage('errorTimeoutTitle') || t.errorTimeoutTitle,
Message: browser.i18n.getMessage('errorTimeoutMessage') || t.errorTimeoutMessage
},
PushExpired: domain => {
return {
Title: browser.i18n.getMessage('errorPushExpiredTitle').replace('DOMAIN', domain),
Message: browser.i18n.getMessage('errorPushExpiredMessage')
Title: (browser.i18n.getMessage('errorPushExpiredTitle') || t.errorPushExpiredTitle).replace('DOMAIN', domain),
Message: browser.i18n.getMessage('errorPushExpiredMessage') || t.errorPushExpiredMessage
};
},
WebSocket: {
Title: browser.i18n.getMessage('errorWebSocketTitle'),
Message: browser.i18n.getMessage('errorWebSocketMessage')
Title: browser.i18n.getMessage('errorWebSocketTitle') || t.errorWebSocketTitle,
Message: browser.i18n.getMessage('errorWebSocketMessage') || t.errorWebSocketMessage
},
OnInstallError: {
Title: browser.i18n.getMessage('errorOnInstallErrorTitle'),
Message: browser.i18n.getMessage('errorOnInstallErrorMessage')
Title: browser.i18n.getMessage('errorOnInstallErrorTitle') || t.errorOnInstallErrorTitle,
Message: browser.i18n.getMessage('errorOnInstallErrorMessage') || t.errorOnInstallErrorMessage
},
ExtNameRequired: {
Title: browser.i18n.getMessage('errorExtNameRequiredTitle'),
Message: browser.i18n.getMessage('errorExtNameRequiredMessage')
Title: browser.i18n.getMessage('errorExtNameRequiredTitle') || t.errorExtNameRequiredTitle,
Message: browser.i18n.getMessage('errorExtNameRequiredMessage') || t.errorExtNameRequiredMessage
},
ExtNameMinLength: {
Title: browser.i18n.getMessage('errorExtNameMinLengthTitle'),
Message: browser.i18n.getMessage('errorExtNameMinLengthMessage')
Title: browser.i18n.getMessage('errorExtNameMinLengthTitle') || t.errorExtNameMinLengthTitle,
Message: browser.i18n.getMessage('errorExtNameMinLengthMessage') || t.errorExtNameMinLengthMessage
},
ExtNameMaxLength: {
Title: browser.i18n.getMessage('errorExtNameMaxLengthTitle'),
Message: browser.i18n.getMessage('errorExtNameMaxLengthMessage')
Title: browser.i18n.getMessage('errorExtNameMaxLengthTitle') || t.errorExtNameMaxLengthTitle,
Message: browser.i18n.getMessage('errorExtNameMaxLengthMessage') || t.errorExtNameMaxLengthMessage
},
ConfigFirst: {
Title: browser.i18n.getMessage('errorConfigFirstTitle'),
Message: browser.i18n.getMessage('errorConfigFirstMessage')
Title: browser.i18n.getMessage('errorConfigFirstTitle') || t.errorConfigFirstTitle,
Message: browser.i18n.getMessage('errorConfigFirstMessage') || t.errorConfigFirstMessage
},
RemoveDeviceBadData: {
Title: browser.i18n.getMessage('errorRemoveDeviceBadDataTitle'),
Message: browser.i18n.getMessage('errorRemoveDeviceBadDataMessage')
Title: browser.i18n.getMessage('errorRemoveDeviceBadDataTitle') || t.errorRemoveDeviceBadDataTitle,
Message: browser.i18n.getMessage('errorRemoveDeviceBadDataMessage') || t.errorRemoveDeviceBadDataMessage
},
StorageCorrupted: {
Title: browser.i18n.getMessage('errorStorageCorruptedTitle'),
Message: browser.i18n.getMessage('errorStorageCorruptedMessage')
Title: browser.i18n.getMessage('errorStorageCorruptedTitle') || t.errorStorageCorruptedTitle,
Message: browser.i18n.getMessage('errorStorageCorruptedMessage') || t.errorStorageCorruptedMessage
},
InactiveTab: {
Title: browser.i18n.getMessage('errorInactiveTabTitle'),
Message: browser.i18n.getMessage('errorInactiveTabMessage')
Title: browser.i18n.getMessage('errorInactiveTabTitle') || t.errorInactiveTabTitle,
Message: browser.i18n.getMessage('errorInactiveTabMessage') || t.errorInactiveTabMessage
}
},
Warning: {
TooSoon: diff => {
return {
Title: browser.i18n.getMessage('warningTooSoonTitle'),
Message: browser.i18n.getMessage('warningTooSoonMessage').replace('DIFF', 10 - Math.round(diff))
Title: browser.i18n.getMessage('warningTooSoonTitle') || t.warningTooSoonTitle,
Message: (browser.i18n.getMessage('warningTooSoonMessage') || t.warningTooSoonMessage).replace('DIFF', 10 - Math.round(diff))
}
},
SelectInput: {
Title: browser.i18n.getMessage('warningSelectInputTitle'),
Message: browser.i18n.getMessage('warningSelectInputMessage')
Title: browser.i18n.getMessage('warningSelectInputTitle') || t.warningSelectInputTitle,
Message: browser.i18n.getMessage('warningSelectInputMessage') || t.warningSelectInputMessage
}
},
Success: {
PushSent: {
Title: browser.i18n.getMessage('successPushSentTitle'),
Message: browser.i18n.getMessage('successPushSentMessage')
Title: browser.i18n.getMessage('successPushSentTitle') || t.successPushSentTitle,
Message: browser.i18n.getMessage('successPushSentMessage') || t.successPushSentMessage
},
ExtNameUpdated: {
Title: browser.i18n.getMessage('successExtNameUpdatedTitle'),
Message: browser.i18n.getMessage('successExtNameUpdatedMessage')
Title: browser.i18n.getMessage('successExtNameUpdatedTitle') || t.successExtNameUpdatedTitle,
Message: browser.i18n.getMessage('successExtNameUpdatedMessage') || t.successExtNameUpdatedMessage
},
DeviceDisconnected: {
Title: browser.i18n.getMessage('successDeviceDisconnectedTitle'),
Message: browser.i18n.getMessage('successDeviceDisconnectedMessage')
Title: browser.i18n.getMessage('successDeviceDisconnectedTitle') || t.successDeviceDisconnectedTitle,
Message: browser.i18n.getMessage('successDeviceDisconnectedMessage') || t.successDeviceDisconnectedMessage
},
SafariReset: {
Title: browser.i18n.getMessage('successSafariResetTitle'),
Message: browser.i18n.getMessage('successSafariResetMessage')
Title: browser.i18n.getMessage('successSafariResetTitle') || t.successSafariResetTitle,
Message: browser.i18n.getMessage('successSafariResetMessage') || t.successSafariResetMessage
}
},
Info: {
NativeNotifications: {
Title: browser.i18n.getMessage('infoNativeNotificationsTitle'),
Message: browser.i18n.getMessage('infoNativeNotificationsMessage')
Title: browser.i18n.getMessage('infoNativeNotificationsTitle') || t.infoNativeNotificationsTitle,
Message: browser.i18n.getMessage('infoNativeNotificationsMessage') || t.infoNativeNotificationsMessage
},
EnabledNativeNotifications: browser.i18n.getMessage('infoEnabledNativeNotifications'),
EnabledNativeNotifications: browser.i18n.getMessage('infoEnabledNativeNotifications') || t.infoEnabledNativeNotifications,
UnsupportedProtocol: {
Title: browser.i18n.getMessage('infoUnsupportedProtocolTitle'),
Message: browser.i18n.getMessage('infoUnsupportedProtocolMessage')
Title: browser.i18n.getMessage('infoUnsupportedProtocolTitle') || t.infoUnsupportedProtocolTitle,
Message: browser.i18n.getMessage('infoUnsupportedProtocolMessage') || t.infoUnsupportedProtocolMessage
},
BrowserActionWithoutTab: {
Title: browser.i18n.getMessage('infoBrowserActionWithoutTabTitle'),
Message: browser.i18n.getMessage('infoBrowserActionWithoutTabMessage')
Title: browser.i18n.getMessage('infoBrowserActionWithoutTabTitle') || t.infoBrowserActionWithoutTabTitle,
Message: browser.i18n.getMessage('infoBrowserActionWithoutTabMessage') || t.infoBrowserActionWithoutTabMessage
},
Test: {
Title: browser.i18n.getMessage('infoTestTitle'),
Message: browser.i18n.getMessage('infoTestMessage')
Title: browser.i18n.getMessage('infoTestTitle') || t.infoTestTitle,
Message: browser.i18n.getMessage('infoTestMessage') || t.infoTestMessage
}
}
}

View File

@ -33,7 +33,7 @@ const generateShortcutBox = () => {
data = data.filter(command => command.name === 'tokenRequest');
data[0].shortcut =
data[0].shortcut
data[0]?.shortcut
.replace(/⌘/g, 'Cmd+')
.replace(/⇧/g, 'Shift+')
.replace(/⌥/g, 'Alt+')
@ -68,7 +68,7 @@ const generateShortcutBox = () => {
const elementsLength = s.length;
s.reverse().forEach((btn, i) => {
const filteredBtn = btn.replace('MacCtrl', 'Ctrl');
const filteredBtn = btn?.replace('MacCtrl', 'Ctrl');
const btnBox = createTextElement('div', filteredBtn);
btnBox.classList.add('twofas-shortcut-edit-box-btn');
box.prepend(btnBox);
@ -82,7 +82,7 @@ const generateShortcutBox = () => {
const text = document.querySelector(S.optionsPage.shortcut.editText);
if (text) {
text.textContent = data[0].shortcut.replace('MacCtrl', 'Ctrl');
text.textContent = data[0]?.shortcut.replace('MacCtrl', 'Ctrl');
}
const editBtn = document.querySelector(S.optionsPage.shortcut.edit);