fix: localize plugin operation errors
This commit is contained in:
@@ -402,11 +402,18 @@
|
||||
}).filter(function (item) { return item !== null; });
|
||||
}
|
||||
|
||||
function reportError(key, fallback, err) {
|
||||
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
||||
console.warn('[verstak.todo] ' + key, err);
|
||||
}
|
||||
statusText = tr(key, null, fallback);
|
||||
statusClass = 'error';
|
||||
}
|
||||
|
||||
function syncNotifications() {
|
||||
if (!api || !api.notifications || typeof api.notifications.replace !== 'function') return Promise.resolve();
|
||||
return api.notifications.replace(notificationRequests()).catch(function (err) {
|
||||
statusText = tr('ui.notificationError', { error: err && err.message ? err.message : String(err) }, 'Could not schedule reminders: ' + (err && err.message ? err.message : String(err)));
|
||||
statusClass = 'error';
|
||||
reportError('ui.notificationError', 'Could not schedule reminders. Please try again.', err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -415,8 +422,7 @@
|
||||
return api.settings.write(GLOBAL_KEY, storageTodos(sortTodos(todos))).then(function () {
|
||||
return syncNotifications();
|
||||
}).catch(function (err) {
|
||||
statusText = tr('ui.saveError', { error: err && err.message ? err.message : String(err) }, 'Could not save todos: ' + (err && err.message ? err.message : String(err)));
|
||||
statusClass = 'error';
|
||||
reportError('ui.saveError', 'Could not save tasks. Please try again.', err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -426,8 +432,7 @@
|
||||
todos = sortTodos(normalizeTodos((settings || {})[GLOBAL_KEY]));
|
||||
return syncNotifications();
|
||||
}).catch(function (err) {
|
||||
statusText = tr('ui.loadError', { error: err && err.message ? err.message : String(err) }, 'Could not load todos: ' + (err && err.message ? err.message : String(err)));
|
||||
statusClass = 'error';
|
||||
reportError('ui.loadError', 'Could not load tasks. Please try again.', err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
"ui.add": "Add Todo",
|
||||
"ui.allWorkspaces": "All workspaces",
|
||||
"ui.unassigned": "Unassigned",
|
||||
"ui.saveError": "Could not save todos: {error}",
|
||||
"ui.loadError": "Could not load todos: {error}",
|
||||
"ui.notificationError": "Could not schedule reminders: {error}",
|
||||
"ui.saveError": "Could not save tasks. Please try again.",
|
||||
"ui.loadError": "Could not load tasks. Please try again.",
|
||||
"ui.notificationError": "Could not schedule reminders. Please try again.",
|
||||
"ui.notificationTitle": "Todo reminder",
|
||||
"ui.notificationBody": "{title}",
|
||||
"ui.titlePlaceholder": "Todo title",
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
"ui.add": "Добавить задачу",
|
||||
"ui.allWorkspaces": "Все рабочие пространства",
|
||||
"ui.unassigned": "Не назначено",
|
||||
"ui.saveError": "Не удалось сохранить задачи: {error}",
|
||||
"ui.loadError": "Не удалось загрузить задачи: {error}",
|
||||
"ui.notificationError": "Не удалось запланировать напоминания: {error}",
|
||||
"ui.saveError": "Не удалось сохранить задачи. Повторите попытку.",
|
||||
"ui.loadError": "Не удалось загрузить задачи. Повторите попытку.",
|
||||
"ui.notificationError": "Не удалось запланировать напоминания. Повторите попытку.",
|
||||
"ui.notificationTitle": "Напоминание о задаче",
|
||||
"ui.notificationBody": "{title}",
|
||||
"ui.titlePlaceholder": "Название задачи",
|
||||
|
||||
Reference in New Issue
Block a user