mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
SETTINGS_LABELS remove 'LABEL_' and '_NAME' part
This commit is contained in:
parent
bf45070ff1
commit
508c262a4b
69 changed files with 606 additions and 682 deletions
|
|
@ -24,33 +24,34 @@ const
|
|||
return key ? I18N_DATA.NOTIFICATIONS[i18nKey(key).replace('_NOTIFICATION', '_ERROR')] : '';
|
||||
},
|
||||
|
||||
fromNow = date => relativeTime(Math.round((date.getTime() - Date.now()) / 1000));
|
||||
|
||||
export const
|
||||
translateTrigger = ko.observable(false),
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat
|
||||
// see /snappymail/v/0.0.0/app/localization/relativetimeformat/
|
||||
fromNow = date => {
|
||||
relativeTime = seconds => {
|
||||
let unit = 'second',
|
||||
value = Math.round((date.getTime() - Date.now()) / 1000),
|
||||
t = [[60,'minute'],[3600,'hour'],[86400,'day'],[2628000,'month'],[31536000,'year']],
|
||||
i = 5,
|
||||
abs = Math.abs(value);
|
||||
abs = Math.abs(seconds);
|
||||
while (i--) {
|
||||
if (t[i][0] <= abs) {
|
||||
value = Math.round(value / t[i][0]);
|
||||
seconds = Math.round(seconds / t[i][0]);
|
||||
unit = t[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Intl.RelativeTimeFormat) {
|
||||
let rtf = new Intl.RelativeTimeFormat(doc.documentElement.lang);
|
||||
return rtf.format(value, unit);
|
||||
return rtf.format(seconds, unit);
|
||||
}
|
||||
abs = Math.abs(value);
|
||||
let rtf = rl.relativeTime.long[unit][0 > value ? 'past' : 'future'],
|
||||
abs = Math.abs(seconds);
|
||||
let rtf = rl.relativeTime.long[unit][0 > seconds ? 'past' : 'future'],
|
||||
plural = rl.relativeTime.plural(abs);
|
||||
return (rtf[plural] || rtf).replace('{0}', abs);
|
||||
};
|
||||
|
||||
export const
|
||||
translateTrigger = ko.observable(false),
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ export class AbstractSettingsScreen extends AbstractScreen {
|
|||
export function settingsAddViewModel(SettingsViewModelClass, template, labelName, route, isDefault = false) {
|
||||
let name = SettingsViewModelClass.name.replace(/(User|Admin)Settings/, '');
|
||||
SettingsViewModelClass.__rlSettingsData = {
|
||||
label: labelName || 'SETTINGS_LABELS/LABEL_' + name.toUpperCase() + '_NAME',
|
||||
label: labelName || 'SETTINGS_LABELS/' + name.toUpperCase(),
|
||||
route: route || name.toLowerCase(),
|
||||
selected: ko.observable(false),
|
||||
template: template || SettingsViewModelClass.name,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { SettingsCapa } from 'Common/Globals';
|
||||
import { i18n, translateTrigger } from 'Common/Translator';
|
||||
import { i18n, translateTrigger, relativeTime } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
|
|
@ -21,19 +21,18 @@ export class UserSettingsSecurity extends AbstractViewSettings {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params);
|
||||
this.autoLogout = SettingsUserStore.autoLogout;
|
||||
this.autoLogoutOptions = koComputable(() => {
|
||||
translateTrigger();
|
||||
return [
|
||||
{ id: 0, name: i18nLogout('NEVER_OPTION_NAME') },
|
||||
{ id: 5, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 5 }) },
|
||||
{ id: 10, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 10 }) },
|
||||
{ id: 30, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 30 }) },
|
||||
{ id: 60, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 60 }) },
|
||||
{ id: 60 * 2, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 2 }) },
|
||||
{ id: 60 * 5, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 5 }) },
|
||||
{ id: 60 * 10, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 10 }) }
|
||||
{ id: 0, name: i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME') },
|
||||
{ id: 5, name: relativeTime(300) },
|
||||
{ id: 10, name: relativeTime(600) },
|
||||
{ id: 30, name: relativeTime(1800) },
|
||||
{ id: 60, name: relativeTime(3600) },
|
||||
{ id: 120, name: relativeTime(7200) },
|
||||
{ id: 300, name: relativeTime(18000) },
|
||||
{ id: 600, name: relativeTime(36000) }
|
||||
];
|
||||
});
|
||||
this.addSetting('AutoLogout');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue