Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marius-wieschollek/passwords-webextension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2020-12-20 18:09:56 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2020-12-20 18:09:56 +0300
commit1cfd4b6614a4a05c511fdc96ec91296647c73c75 (patch)
tree2d46dfff14750c9181dbcf73df3cbc35adcc5e77
parent345f7f0d2528cff8a706b6cec6e7ea841a650570 (diff)
Add option to disable localisation
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
-rw-r--r--src/js/App/Background.js3
-rw-r--r--src/js/App/Options.js2
-rw-r--r--src/js/App/Passlink.js2
-rw-r--r--src/js/App/Popup.js2
-rw-r--r--src/js/Controller/Options/DebugData.js15
-rw-r--r--src/js/Controller/Setting/Get.js3
-rw-r--r--src/js/Controller/Setting/Set.js3
-rw-r--r--src/js/Manager/ErrorManager.js40
-rw-r--r--src/js/Services/LocalisationService.js16
-rw-r--r--src/js/Settings/MasterSettingsProvider.js6
-rw-r--r--src/platform/generic/_locales/de/messages.json28
-rw-r--r--src/platform/generic/_locales/en/messages.json24
-rw-r--r--src/vue/Components/Options/Debug.vue83
13 files changed, 187 insertions, 40 deletions
diff --git a/src/js/App/Background.js b/src/js/App/Background.js
index e344f45..4818691 100644
--- a/src/js/App/Background.js
+++ b/src/js/App/Background.js
@@ -16,6 +16,8 @@ import ThemeService from '@js/Services/ThemeService';
import ThemeRepository from '@js/Repositories/ThemeRepository';
import SettingsService from '@js/Services/SettingsService';
import MasterSettingsProvider from '@js/Settings/MasterSettingsProvider';
+import LocalisationService from "@js/Services/LocalisationService";
+import ToastService from "@js/Services/ToastService";
class Background {
async init() {
@@ -37,6 +39,7 @@ class Background {
ContextMenuManager.init();
MiningManager.init();
await ServerManager.init();
+ await LocalisationService.init();
} catch(e) {
ErrorManager.logError(e);
}
diff --git a/src/js/App/Options.js b/src/js/App/Options.js
index eb4f8ee..9201f9f 100644
--- a/src/js/App/Options.js
+++ b/src/js/App/Options.js
@@ -8,6 +8,7 @@ import ToastService from '@js/Services/ToastService';
import ThemeService from '@js/Services/ThemeService';
import SettingsService from '@js/Services/SettingsService';
import ClientSettingsProvider from '@js/Settings/ClientSettingsProvider';
+import LocalisationService from "@js/Services/LocalisationService";
class Options {
@@ -34,6 +35,7 @@ class Options {
SettingsService.init(ClientSettingsProvider);
await ThemeService.apply();
+ await LocalisationService.init();
await this._initVue();
await ToastService.init();
} catch(e) {
diff --git a/src/js/App/Passlink.js b/src/js/App/Passlink.js
index b7aefff..17d1fbe 100644
--- a/src/js/App/Passlink.js
+++ b/src/js/App/Passlink.js
@@ -8,6 +8,7 @@ import ToastService from '@js/Services/ToastService';
import ThemeService from '@js/Services/ThemeService';
import SettingsService from '@js/Services/SettingsService';
import ClientSettingsProvider from '@js/Settings/ClientSettingsProvider';
+import LocalisationService from "@js/Services/LocalisationService";
class Passlink {
@@ -32,6 +33,7 @@ class Passlink {
await MessageService.init(true, 'background');
ConverterManager.init();
SettingsService.init(ClientSettingsProvider);
+ await LocalisationService.init();
let urlParams = new URLSearchParams(window.location.search),
link = urlParams.get('link'),
diff --git a/src/js/App/Popup.js b/src/js/App/Popup.js
index 6b33053..9a934db 100644
--- a/src/js/App/Popup.js
+++ b/src/js/App/Popup.js
@@ -9,6 +9,7 @@ import ToastService from '@js/Services/ToastService';
import ThemeService from '@js/Services/ThemeService';
import SettingsService from '@js/Services/SettingsService';
import ClientSettingsProvider from '@js/Settings/ClientSettingsProvider';
+import LocalisationService from "@js/Services/LocalisationService";
class Popup {
@@ -46,6 +47,7 @@ class Popup {
this._authClient = new AuthorisationClient();
await ThemeService.apply();
+ await LocalisationService.init();
await this._initVue();
await ToastService.init();
} catch(e) {
diff --git a/src/js/Controller/Options/DebugData.js b/src/js/Controller/Options/DebugData.js
index fb2c84a..fec2f31 100644
--- a/src/js/Controller/Options/DebugData.js
+++ b/src/js/Controller/Options/DebugData.js
@@ -2,6 +2,7 @@ import AbstractController from '@js/Controller/AbstractController';
import HiddenFolderHelper from "@js/Helper/HiddenFolderHelper";
import ErrorManager from "@js/Manager/ErrorManager";
import ServerManager from "@js/Manager/ServerManager";
+import SettingsService from "@js/Services/SettingsService";
export default class DebugData extends AbstractController {
@@ -12,8 +13,9 @@ export default class DebugData extends AbstractController {
*/
async execute(message, reply) {
let data = {
- hidden: {id: null},
- errors: ErrorManager.errors
+ hidden : {id: null},
+ errors : ErrorManager.errors,
+ settings: {localisations: false}
};
try {
@@ -21,7 +23,14 @@ export default class DebugData extends AbstractController {
helper = new HiddenFolderHelper();
data.hidden.id = await helper.getHiddenFolderId(api);
} catch(e) {
- ErrorManager.logError(e)
+ ErrorManager.logError(e);
+ }
+
+ try {
+ let value = await SettingsService.getValue('debug.localisation.enabled');
+ data.settings.localize = !value;
+ } catch(e) {
+ ErrorManager.logError(e);
}
reply
diff --git a/src/js/Controller/Setting/Get.js b/src/js/Controller/Setting/Get.js
index f9e19e0..8c29300 100644
--- a/src/js/Controller/Setting/Get.js
+++ b/src/js/Controller/Setting/Get.js
@@ -16,7 +16,8 @@ export default class Get extends AbstractController {
'notification.password.update',
'server.default',
'theme.current',
- 'theme.custom'
+ 'theme.custom',
+ 'debug.localisation.enabled'
];
}
diff --git a/src/js/Controller/Setting/Set.js b/src/js/Controller/Setting/Set.js
index b3d901d..b9d439c 100644
--- a/src/js/Controller/Setting/Set.js
+++ b/src/js/Controller/Setting/Set.js
@@ -12,7 +12,8 @@ export default class Set extends AbstractController {
'password.autosubmit',
'popup.related.search',
'notification.password.new',
- 'notification.password.update'
+ 'notification.password.update',
+ 'debug.localisation.enabled'
];
}
diff --git a/src/js/Manager/ErrorManager.js b/src/js/Manager/ErrorManager.js
index f7dc53a..016dab3 100644
--- a/src/js/Manager/ErrorManager.js
+++ b/src/js/Manager/ErrorManager.js
@@ -82,8 +82,9 @@ class ErrorManager {
details = this._getErrorFromEvent(message, file, line, col);
}
- let errorObject = {details, error};
- console.error(details.message, errorObject, details.stack);
+ let errorData = this._convertErrorToObject(error),
+ errorObject = {details, error: errorData};
+ console.error(details.message, error, errorObject, details.stack);
if(this._mode === 'server') {
this._saveError(errorObject);
@@ -94,6 +95,28 @@ class ErrorManager {
/**
*
+ * @param {(Error|Object)} error
+ * @returns {*}
+ * @private
+ */
+ _convertErrorToObject(error) {
+ if(error instanceof Error) {
+ return {
+ columnNumber: error.columnNumber ? error.columnNumber:undefined,
+ fileName : error.fileName ? error.fileName:undefined,
+ lineNumber : error.lineNumber ? error.lineNumber:undefined,
+ message : error.message ? error.message:undefined,
+ name : error.name ? error.name:undefined,
+ stack : error.stack ? error.stack:undefined,
+ string : error.toString()
+ };
+ }
+
+ return error;
+ }
+
+ /**
+ *
* @param {String} message
* @param {String} file
* @param {String} line
@@ -123,7 +146,7 @@ class ErrorManager {
return {
data,
stack: error.stack ? error.stack:'',
- time: Date.now()
+ time : Date.now()
};
}
@@ -176,10 +199,11 @@ class ErrorManager {
* @private
*/
_addQueueConsumer() {
- SystemService.waitReady()
+ SystemService
+ .waitReady()
.then(() => {
MessageService.listen(
- 'queue.items.error',
+ 'queue.items',
(message) => {
return this._processQueueItems(message);
}
@@ -194,7 +218,11 @@ class ErrorManager {
*/
_processQueueItems(message) {
let payload = message.getPayload();
- this._saveError(payload);
+ if(payload && payload.name === 'error') {
+ for(let item of payload.items) {
+ this._saveError(item.task);
+ }
+ }
}
}
diff --git a/src/js/Services/LocalisationService.js b/src/js/Services/LocalisationService.js
index b9d4420..258b1bf 100644
--- a/src/js/Services/LocalisationService.js
+++ b/src/js/Services/LocalisationService.js
@@ -1,9 +1,22 @@
import SystemService from "@js/Services/SystemService";
+import SettingsService from "@js/Services/SettingsService";
class LocalisationService {
constructor() {
this._browser = SystemService.getBrowserApi();
+ this._debug = null;
+ }
+
+ /**
+ *
+ */
+ init() {
+ SettingsService
+ .get('debug.localisation.enabled')
+ .then((s) => {
+ this._debug = s;
+ });
}
/**
@@ -12,7 +25,8 @@ class LocalisationService {
* @param {(String|String[])} [variables]
* @returns {String}
*/
- translate(key, ...variables ) {
+ translate(key, ...variables) {
+ if(this._debug && !this._debug.getValue()) return key;
if(Array.isArray(key)) {
if(key.length < 0) return '';
diff --git a/src/js/Settings/MasterSettingsProvider.js b/src/js/Settings/MasterSettingsProvider.js
index 56db00b..a423c45 100644
--- a/src/js/Settings/MasterSettingsProvider.js
+++ b/src/js/Settings/MasterSettingsProvider.js
@@ -60,6 +60,9 @@ class MasterSettingsProvider {
'theme.custom' : [
'sync.theme.custom',
'local.theme.custom'
+ ],
+ 'debug.localisation.enabled' : [
+ 'local.localisation.enabled'
]
};
this._defaults = {
@@ -71,7 +74,8 @@ class MasterSettingsProvider {
'password.autosubmit' : true,
'password.folder.private' : null,
'notification.password.new' : true,
- 'notification.password.update': true
+ 'notification.password.update': true,
+ 'debug.localisation.enabled' : true
};
}
diff --git a/src/platform/generic/_locales/de/messages.json b/src/platform/generic/_locales/de/messages.json
index 8f5f083..ea4edba 100644
--- a/src/platform/generic/_locales/de/messages.json
+++ b/src/platform/generic/_locales/de/messages.json
@@ -29,6 +29,20 @@
}
}
},
+ "UserAgent" : {
+ "message" : "Offizielle Passwords $BROWSER$ Extension auf $OS$",
+ "description" : "The user agent used for api requests. Only ASCII characters allowed",
+ "placeholders": {
+ "browser": {
+ "content": "$1",
+ "example": "Firefox"
+ },
+ "os" : {
+ "content": "$2",
+ "example": "Linux"
+ }
+ }
+ },
"MigrationAccountName" : {
"message" : "Nextcloud Konto",
"description": "Label assigned to the account used by the v1.x migration"
@@ -1011,15 +1025,15 @@
"message" : "Interner Status",
"description": ""
},
- "DebugInfoExtensionVersion" : {
+ "DebugInfoExtensionVersion" : {
"message" : "Extension Version",
"description": ""
},
- "DebugInfoExtensionPlatform" : {
+ "DebugInfoExtensionPlatform" : {
"message" : "Extension Plattform",
"description": ""
},
- "DebugInfoExtensionEnvironment" : {
+ "DebugInfoExtensionEnvironment" : {
"message" : "Extension Modus",
"description": ""
},
@@ -1027,6 +1041,14 @@
"message" : "ID des Ordners für private Passwörter",
"description": ""
},
+ "DebugSettings" : {
+ "message" : "Entwicklereinstellungen",
+ "description": "Headline above the debugging settings section in the extension settings in the debug tab"
+ },
+ "DebugLanguageTagsEnabled" : {
+ "message" : "Sprach-Tags anzeigen",
+ "description": "Label of the setting to disable translation of language keys in the debug settings section in the debug tab in the extension settings"
+ },
"DebugErrorLog" : {
"message" : "Fehlerberichte",
"description": ""
diff --git a/src/platform/generic/_locales/en/messages.json b/src/platform/generic/_locales/en/messages.json
index 706f0a8..5f0c734 100644
--- a/src/platform/generic/_locales/en/messages.json
+++ b/src/platform/generic/_locales/en/messages.json
@@ -49,23 +49,23 @@
},
"SettingsTabAccounts" : {
"message" : "Accounts",
- "description": ""
+ "description": "Label of the user accounts tab in the extension settings"
},
"SettingsTabTheming" : {
"message" : "Theming",
- "description": ""
+ "description": "Label of the themes tab in the extension settings"
},
"SettingsTabOther" : {
"message" : "Other Settings",
- "description": ""
+ "description": "Label of the general settings tab in the extension settings"
},
"SettingsTabDebug" : {
"message" : "Debug",
- "description": ""
+ "description": "Label of the extension debugging tab in the extension settings"
},
"SettingsAccountsMain" : {
"message" : "Default account for new passwords",
- "description": ""
+ "description": "Label of the option to choose the main account in the extension settings. This account will be used to synchronize settings accross apps, store new passwords and so on"
},
"AutofillSettings" : {
"message" : "Password autofill",
@@ -1025,15 +1025,15 @@
"message" : "Internal Status",
"description": "Headline above the internal status section in the extension settings in the debug tab"
},
- "DebugInfoExtensionVersion" : {
+ "DebugInfoExtensionVersion" : {
"message" : "Extension Version",
"description": "Description of the extension version in the internal status section in the debug tab in the extension settings"
},
- "DebugInfoExtensionPlatform" : {
+ "DebugInfoExtensionPlatform" : {
"message" : "Extension Platform",
"description": "Description of the extension platform (firefox or chrome) in the internal status section in the debug tab in the extension settings"
},
- "DebugInfoExtensionEnvironment" : {
+ "DebugInfoExtensionEnvironment" : {
"message" : "Extension Mode",
"description": "Description of the extension mode (production or development) in the internal status section in the debug tab in the extension settings"
},
@@ -1041,6 +1041,14 @@
"message" : "Hidden Passwords Folder ID",
"description": "Description of the id of the folder used to store hidden/private passwords in the internal status section in the debug tab in the extension settings"
},
+ "DebugSettings" : {
+ "message" : "Debugging Settings",
+ "description": "Headline above the debugging settings section in the extension settings in the debug tab"
+ },
+ "DebugLanguageTagsEnabled" : {
+ "message" : "Show language keys",
+ "description": "Label of the setting to disable translation of language keys in the debug settings section in the debug tab in the extension settings"
+ },
"DebugErrorLog" : {
"message" : "Error Log",
"description": "Headline above the error logs section in the extension settings in the debug tab"
diff --git a/src/vue/Components/Options/Debug.vue b/src/vue/Components/Options/Debug.vue
index 3dccd6a..a4be99b 100644
--- a/src/vue/Components/Options/Debug.vue
+++ b/src/vue/Components/Options/Debug.vue
@@ -18,6 +18,12 @@
<span class="value">{{ hidden.id }}</span>
</div>
+ <translate tag="h3" say="DebugSettings"/>
+ <div class="debug-info">
+ <translate tag="label" class="label" say="DebugLanguageTagsEnabled"/>
+ <slider-field v-model="settings.localize"/>
+ </div>
+
<translate tag="h3" say="DebugErrorLog"/>
<div class="debug-error-item" v-for="error in errors">
<div class="error-message" v-if="error.details && error.details.message" @click="showData">
@@ -37,38 +43,75 @@
import ToastService from "@js/Services/ToastService";
import ErrorManager from "@js/Manager/ErrorManager";
import LocalisationService from "@js/Services/LocalisationService";
+ import SliderField from "@vue/Components/Form/SliderField";
+ import SettingsService from "@js/Services/SettingsService";
export default {
- components: {Icon, Translate},
+ components: {SliderField, Icon, Translate},
data() {
return {
- hidden: {
+ hidden : {
id: ''
},
- errors: [],
- app: {
- version: process.env.APP_VERSION,
- platform: process.env.APP_PLATFORM,
+ errors : [],
+ app : {
+ version : process.env.APP_VERSION,
+ platform : process.env.APP_PLATFORM,
environment: process.env.NODE_ENV
- }
+ },
+ settings: {
+ localize: false
+ },
+ interval: null
};
},
mounted() {
- MessageService.send('options.debug.data').then((reply) => {
- let data = reply.getPayload();
+ this.loadData();
+ if(!this.interval) {
+ this.interval = setInterval(() => {
+ this.loadData();
+ }, 5000);
+ }
+ },
- if(data.hasOwnProperty('hidden')) {
- this.hidden = data.hidden;
- }
+ beforeDestroy() {
+ clearInterval(this.interval);
+ this.interval = null;
+ },
- if(data.hasOwnProperty('errors')) {
- this.errors = data.errors;
- }
- });
+ activated() {
+ this.loadData();
+ if(!this.interval) {
+ this.interval = setInterval(() => {
+ this.loadData();
+ }, 5000);
+ }
+ },
+
+ deactivated() {
+ clearInterval(this.interval);
+ this.interval = null;
},
methods: {
+ loadData() {
+ MessageService.send('options.debug.data').then((reply) => {
+ let data = reply.getPayload();
+
+ if(data.hasOwnProperty('hidden')) {
+ this.hidden = data.hidden;
+ }
+
+ if(data.hasOwnProperty('errors')) {
+ this.errors = data.errors;
+ }
+
+ if(data.hasOwnProperty('settings')) {
+ this.settings = data.settings;
+ }
+ });
+ },
getTitle(error) {
if(error.details) {
let label = '';
@@ -103,6 +146,14 @@
.success('DebugErrorDataCopied')
.catch(ErrorManager.catchEvt);
}
+ },
+
+ watch: {
+ 'settings.localize': (value) => {
+ SettingsService
+ .set('debug.localisation.enabled', !value)
+ .catch(ErrorManager.catchEvt);
+ }
}
};
</script>