From 1968dd2d085d336e465b4d5336e600cf0413c3a1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 19 Nov 2016 00:21:47 -0500 Subject: [PATCH] use es6 Proxy for i18n service so we don't have to define properties for every string --- src/services/i18nService.js | 119 +++--------------------------------- 1 file changed, 8 insertions(+), 111 deletions(-) diff --git a/src/services/i18nService.js b/src/services/i18nService.js index 905c8758..968f5303 100644 --- a/src/services/i18nService.js +++ b/src/services/i18nService.js @@ -1,113 +1,10 @@ function i18nService() { - return { - appName: chrome.i18n.getMessage('appName'), - loginOrCreateNewAccount: chrome.i18n.getMessage('loginOrCreateNewAccount'), - createAccount: chrome.i18n.getMessage('createAccount'), - login: chrome.i18n.getMessage('login'), - cancel: chrome.i18n.getMessage('cancel'), - close: chrome.i18n.getMessage('close'), - submit: chrome.i18n.getMessage('submit'), - emailAddress: chrome.i18n.getMessage('emailAddress'), - masterPass: chrome.i18n.getMessage('masterPass'), - masterPassDesc: chrome.i18n.getMessage('masterPassDesc'), - reTypeMasterPass: chrome.i18n.getMessage('reTypeMasterPass'), - masterPassHint: chrome.i18n.getMessage('masterPassHint'), - masterPassHintDesc: chrome.i18n.getMessage('masterPassHintDesc'), - tab: chrome.i18n.getMessage('tab'), - myVault: chrome.i18n.getMessage('myVault'), - tools: chrome.i18n.getMessage('tools'), - settings: chrome.i18n.getMessage('settings'), - currentTab: chrome.i18n.getMessage('currentTab'), - copyPassword: chrome.i18n.getMessage('copyPassword'), - copyUsername: chrome.i18n.getMessage('copyUsername'), - autoFill: chrome.i18n.getMessage('autoFill'), - generatePasswordCopied: chrome.i18n.getMessage('generatePasswordCopied'), - noMatchingSites: chrome.i18n.getMessage('noMatchingSites'), - vaultLocked: chrome.i18n.getMessage('vaultLocked'), - autoFillInfo: chrome.i18n.getMessage('autoFillInfo'), - addSite: chrome.i18n.getMessage('addSite'), - passwordHint: chrome.i18n.getMessage('passwordHint'), - enterEmailToGetHint: chrome.i18n.getMessage('enterEmailToGetHint'), - getMasterPasswordHint: chrome.i18n.getMessage('getMasterPasswordHint'), - continue: chrome.i18n.getMessage('continue'), - verificationCode: chrome.i18n.getMessage('verificationCode'), - enterTwoStepVerCode: chrome.i18n.getMessage('enterTwoStepVerCode'), - account: chrome.i18n.getMessage('account'), - changeMasterPassword: chrome.i18n.getMessage('changeMasterPassword'), - changeEmail: chrome.i18n.getMessage('changeEmail'), - twoStepLogin: chrome.i18n.getMessage('twoStepLogin'), - logOut: chrome.i18n.getMessage('logOut'), - about: chrome.i18n.getMessage('about'), - version: chrome.i18n.getMessage('version'), - save: chrome.i18n.getMessage('save'), - addFolder: chrome.i18n.getMessage('addFolder'), - name: chrome.i18n.getMessage('name'), - editFolder: chrome.i18n.getMessage('editFolder'), - deleteFolder: chrome.i18n.getMessage('deleteFolder'), - folders: chrome.i18n.getMessage('folders'), - noFolders: chrome.i18n.getMessage('noFolders'), - helpFeedback: chrome.i18n.getMessage('helpFeedback'), - emailUs: chrome.i18n.getMessage('emailUs'), - emailUsDirectly: chrome.i18n.getMessage('emailUsDirectly'), - visitOurWebsite: chrome.i18n.getMessage('visitOurWebsite'), - visitOurWebsiteDirectly: chrome.i18n.getMessage('visitOurWebsiteDirectly'), - fileBugReport: chrome.i18n.getMessage('fileBugReport'), - gitHubIssue: chrome.i18n.getMessage('gitHubIssue'), - sync: chrome.i18n.getMessage('sync'), - syncVaultNow: chrome.i18n.getMessage('syncVaultNow'), - lastSync: chrome.i18n.getMessage('lastSync'), - passGen: chrome.i18n.getMessage('passGen'), - passGenInfo: chrome.i18n.getMessage('passGenInfo'), - bitWebVault: chrome.i18n.getMessage('bitWebVault'), - bitWebVaultInfo: chrome.i18n.getMessage('bitWebVaultInfo'), - bitIosVault: chrome.i18n.getMessage('bitIosVault'), - bitIosVaultInfo: chrome.i18n.getMessage('bitIosVaultInfo'), - bitAndrVault: chrome.i18n.getMessage('bitAndrVault'), - bitAndrVaultInfo: chrome.i18n.getMessage('bitAndrVaultInfo'), - importLogins: chrome.i18n.getMessage('importLogins'), - importLoginsInfo: chrome.i18n.getMessage('importLoginsInfo'), - select: chrome.i18n.getMessage('select'), - generatePassword: chrome.i18n.getMessage('generatePassword'), - regeneratePassword: chrome.i18n.getMessage('regeneratePassword'), - options: chrome.i18n.getMessage('options'), - length: chrome.i18n.getMessage('length'), - minNumbers: chrome.i18n.getMessage('minNumbers'), - minSpecial: chrome.i18n.getMessage('minSpecial'), - avoidAmbChar: chrome.i18n.getMessage('avoidAmbChar'), - searchVault: chrome.i18n.getMessage('searchVault'), - edit: chrome.i18n.getMessage('edit'), - noSitesInList: chrome.i18n.getMessage('noSitesInList'), - siteInformation: chrome.i18n.getMessage('siteInformation'), - username: chrome.i18n.getMessage('username'), - password: chrome.i18n.getMessage('password'), - favorite: chrome.i18n.getMessage('favorite'), - notes: chrome.i18n.getMessage('notes'), - editSite: chrome.i18n.getMessage('editSite'), - folder: chrome.i18n.getMessage('folder'), - deleteSite: chrome.i18n.getMessage('deleteSite'), - viewSite: chrome.i18n.getMessage('viewSite'), - launchWebsite: chrome.i18n.getMessage('launchWebsite'), - website: chrome.i18n.getMessage('website'), - togglePassword: chrome.i18n.getMessage('togglePassword'), - manage: chrome.i18n.getMessage('manage'), - other: chrome.i18n.getMessage('other'), - disableGa: chrome.i18n.getMessage('disableGa'), - rateExtension: chrome.i18n.getMessage('rateExtension'), - rateExtensionDesc: chrome.i18n.getMessage('rateExtensionDesc'), - browserNotSupportClipboard: chrome.i18n.getMessage('browserNotSupportClipboard'), - verifyMasterPassword: chrome.i18n.getMessage('verifyMasterPassword'), - invalidMasterPassword: chrome.i18n.getMessage('invalidMasterPassword'), - errorsHaveOccurred: chrome.i18n.getMessage('errorsHaveOccurred'), - lockOptions: chrome.i18n.getMessage('lockOptions'), - immediately: chrome.i18n.getMessage('immediately'), - oneMinute: chrome.i18n.getMessage('oneMinute'), - fiveMinutes: chrome.i18n.getMessage('fiveMinutes'), - fifteenMinutes: chrome.i18n.getMessage('fifteenMinutes'), - thirtyMinutes: chrome.i18n.getMessage('thirtyMinutes'), - oneHour: chrome.i18n.getMessage('oneHour'), - fourHours: chrome.i18n.getMessage('fourHours'), - onRestart: chrome.i18n.getMessage('onRestart'), - never: chrome.i18n.getMessage('never'), - security: chrome.i18n.getMessage('security') - }; + return new Proxy({}, { + get: function (target, name) { + return chrome.i18n.getMessage(name); + }, + set: function (target, name, value) { + throw 'set not allowed for i18n'; + } + }); };