Upgrade i18n() to use Object.entries()

And replace quoted object keys to be without quotes
This commit is contained in:
djmaze 2021-03-24 21:26:40 +01:00
parent fe4dbc729c
commit 7eaaa0a793
24 changed files with 224 additions and 231 deletions

View file

@ -226,7 +226,7 @@ class ComposePopupView extends AbstractViewPopup {
sendButtonSuccess: () => !this.sendError() && !this.sendSuccessButSaveError(),
savedTimeText: () =>
this.savedTime() ? i18n('COMPOSE/SAVED_TIME', { 'TIME': this.savedTime().format('LT') }) : '',
this.savedTime() ? i18n('COMPOSE/SAVED_TIME', { TIME: this.savedTime().format('LT') }) : '',
emptyToErrorTooltip: () => (this.emptyToError() ? i18n('COMPOSE/EMPTY_TO_ERROR_DESC') : ''),
@ -254,9 +254,9 @@ class ComposePopupView extends AbstractViewPopup {
identitiesOptions: () =>
IdentityUserStore.map(item => ({
'item': item,
'optValue': item.id(),
'optText': item.formattedName()
item: item,
optValue: item.id(),
optText: item.formattedName()
})),
currentIdentityView: () => {
@ -931,8 +931,8 @@ class ComposePopupView extends AbstractViewPopup {
case ComposeType.ReplyAll:
sFrom = message.fromToLine(false, true);
sReplyTitle = i18n('COMPOSE/REPLY_MESSAGE_TITLE', {
'DATETIME': sDate,
'EMAIL': sFrom
DATETIME: sDate,
EMAIL: sFrom
});
sText = sText.replace(/<img[^>]+>/g, '').replace(/<a\s[^>]+><\/a>/g, '').trim();

View file

@ -49,9 +49,9 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
return null;
}
return oKey.users.map(user => ({
'id': oKey.guid,
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
'key': oKey
id: oKey.guid,
name: '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
key: oKey
}));
});
@ -64,9 +64,9 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
return null;
}
return oKey.users.map(user => ({
'id': oKey.guid,
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
'key': oKey
id: oKey.guid,
name: '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
key: oKey
}));
});
return opts.flat().filter(v => v);
@ -114,7 +114,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
} else if (!this.signKey().key) {
this.notification(
i18nPGP('NO_PRIVATE_KEY_FOUND_FOR', {
'EMAIL': this.signKey().email
EMAIL: this.signKey().email
})
);
@ -150,7 +150,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
} else if (oKey && oKey.email) {
this.notification(
i18nPGP('NO_PUBLIC_KEYS_FOUND_FOR', {
'EMAIL': oKey.email
EMAIL: oKey.email
})
);
@ -196,7 +196,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
this.notification(
i18nPGP('PGP_ERROR', {
'ERROR': '' + e
ERROR: '' + e
})
);
}
@ -211,13 +211,13 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
.catch((e) => {
this.notification(
i18nPGP('PGP_ERROR', {
'ERROR': '' + e
ERROR: '' + e
})
);
});
} catch (e) {
this.notification(
i18nPGP('PGP_ERROR', {'ERROR': '' + e})
i18nPGP('PGP_ERROR', {ERROR: '' + e})
);
}
}
@ -237,11 +237,11 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
if (option) {
this.signKey({
'empty': !option.key,
'selected': ko.observable(!!option.key),
'users': option.key.users,
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
'key': option.key
empty: !option.key,
selected: ko.observable(!!option.key),
users: option.key.users,
hash: option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
key: option.key
});
}
}
@ -252,12 +252,12 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
if (option) {
this.encryptKeys.push({
'empty': !option.key,
'selected': ko.observable(!!option.key),
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
'users': option.key.users,
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
'key': option.key
empty: !option.key,
selected: ko.observable(!!option.key),
removable: ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
users: option.key.users,
hash: option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
key: option.key
});
}
}
@ -343,9 +343,9 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
const keys = PgpUserStore.findAllPrivateKeysByEmailNotNative(emailLine);
if (keys && keys[0]) {
this.signKey({
'users': keys[0].users || [emailLine],
'hash': keys[0].id.substr(KEY_NAME_SUBSTR).toUpperCase(),
'key': keys[0]
users: keys[0].users || [emailLine],
hash: keys[0].id.substr(KEY_NAME_SUBSTR).toUpperCase(),
key: keys[0]
});
}
}
@ -360,14 +360,14 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup {
const keys = PgpUserStore.findAllPublicKeysByEmailNotNative(recEmail);
return keys
? keys.map(publicKey => ({
'empty': !publicKey,
'selected': ko.observable(!!publicKey),
'removable': ko.observable(
empty: !publicKey,
selected: ko.observable(!!publicKey),
removable: ko.observable(
!this.sign() || !this.signKey() || this.signKey().key.id !== publicKey.id
),
'users': publicKey ? publicKey.users || [recEmail] : [recEmail],
'hash': publicKey ? publicKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() : '',
'key': publicKey
users: publicKey ? publicKey.users || [recEmail] : [recEmail],
hash: publicKey ? publicKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() : '',
key: publicKey
}))
: [];
}).flat().validUnique(encryptKey => encryptKey.hash)

View file

@ -63,13 +63,13 @@ class DomainPopupView extends AbstractViewPopup {
let result = '';
if (this.edit()) {
result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { 'NAME': name });
result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { NAME: name });
if (aliasName) {
result += ' ← ' + aliasName;
}
} else {
result = name
? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { 'NAME': name })
? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { NAME: name })
: i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN');
}
@ -78,7 +78,7 @@ class DomainPopupView extends AbstractViewPopup {
domainDesc: () => {
const name = this.name();
return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', { 'NAME': '*@' + name }) : '';
return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', { NAME: '*@' + name }) : '';
},
domainIsComputed: () => {

View file

@ -66,22 +66,22 @@ class FilterPopupView extends AbstractViewPopup {
let i18nFilter = key => i18n('POPUPS_FILTER/SELECT_' + key);
this.fieldOptions([
{ 'id': FilterConditionField.From, 'name': i18n('GLOBAL/FROM') },
{ 'id': FilterConditionField.Recipient, 'name': i18nFilter('FIELD_RECIPIENTS') },
{ 'id': FilterConditionField.Subject, 'name': i18n('GLOBAL/SUBJECT') },
{ 'id': FilterConditionField.Size, 'name': i18nFilter('FIELD_SIZE') },
{ 'id': FilterConditionField.Header, 'name': i18nFilter('FIELD_HEADER') }
{ id: FilterConditionField.From, name: i18n('GLOBAL/FROM') },
{ id: FilterConditionField.Recipient, name: i18nFilter('FIELD_RECIPIENTS') },
{ id: FilterConditionField.Subject, name: i18n('GLOBAL/SUBJECT') },
{ id: FilterConditionField.Size, name: i18nFilter('FIELD_SIZE') },
{ id: FilterConditionField.Header, name: i18nFilter('FIELD_HEADER') }
]);
this.typeOptions([
{ 'id': FilterConditionType.Contains, 'name': i18nFilter('TYPE_CONTAINS') },
{ 'id': FilterConditionType.NotContains, 'name': i18nFilter('TYPE_NOT_CONTAINS') },
{ 'id': FilterConditionType.EqualTo, 'name': i18nFilter('TYPE_EQUAL_TO') },
{ 'id': FilterConditionType.NotEqualTo, 'name': i18nFilter('TYPE_NOT_EQUAL_TO') }
{ id: FilterConditionType.Contains, name: i18nFilter('TYPE_CONTAINS') },
{ id: FilterConditionType.NotContains, name: i18nFilter('TYPE_NOT_CONTAINS') },
{ id: FilterConditionType.EqualTo, name: i18nFilter('TYPE_EQUAL_TO') },
{ id: FilterConditionType.NotEqualTo, name: i18nFilter('TYPE_NOT_EQUAL_TO') }
]);
// this.actionTypeOptions.push({'id': FilterAction.None,
// 'name': i18n('GLOBAL/NONE')});
// this.actionTypeOptions.push({id: FilterAction.None,
// name: i18n('GLOBAL/NONE')});
const modules = SieveUserStore.capa;
if (modules) {
if (modules.includes('imap4flags')) {
@ -90,45 +90,45 @@ class FilterPopupView extends AbstractViewPopup {
if (modules.includes('fileinto')) {
this.actionTypeOptions.push({
'id': FilterAction.MoveTo,
'name': i18nFilter('ACTION_MOVE_TO')
id: FilterAction.MoveTo,
name: i18nFilter('ACTION_MOVE_TO')
});
this.actionTypeOptions.push({
'id': FilterAction.Forward,
'name': i18nFilter('ACTION_FORWARD_TO')
id: FilterAction.Forward,
name: i18nFilter('ACTION_FORWARD_TO')
});
}
if (modules.includes('reject')) {
this.actionTypeOptions.push({ 'id': FilterAction.Reject, 'name': i18nFilter('ACTION_REJECT') });
this.actionTypeOptions.push({ id: FilterAction.Reject, name: i18nFilter('ACTION_REJECT') });
}
if (modules.includes('vacation')) {
this.actionTypeOptions.push({
'id': FilterAction.Vacation,
'name': i18nFilter('ACTION_VACATION_MESSAGE')
id: FilterAction.Vacation,
name: i18nFilter('ACTION_VACATION_MESSAGE')
});
}
if (modules.includes('body')) {
this.fieldOptions.push({ 'id': FilterConditionField.Body, 'name': i18nFilter('FIELD_BODY') });
this.fieldOptions.push({ id: FilterConditionField.Body, name: i18nFilter('FIELD_BODY') });
}
if (modules.includes('regex')) {
this.typeOptions.push({ 'id': FilterConditionType.Regex, 'name': 'Regex' });
this.typeOptions.push({ id: FilterConditionType.Regex, name: 'Regex' });
}
}
this.actionTypeOptions.push({ 'id': FilterAction.Discard, 'name': i18nFilter('ACTION_DISCARD') });
this.actionTypeOptions.push({ id: FilterAction.Discard, name: i18nFilter('ACTION_DISCARD') });
this.typeOptionsSize([
{ 'id': FilterConditionType.Over, 'name': i18nFilter('TYPE_OVER') },
{ 'id': FilterConditionType.Under, 'name': i18nFilter('TYPE_UNDER') }
{ id: FilterConditionType.Over, name: i18nFilter('TYPE_OVER') },
{ id: FilterConditionType.Under, name: i18nFilter('TYPE_UNDER') }
]);
this.typeOptionsBody([
{ 'id': FilterConditionType.Text, 'name': i18nFilter('TYPE_TEXT') },
{ 'id': FilterConditionType.Raw, 'name': i18nFilter('TYPE_RAW') }
{ id: FilterConditionType.Text, name: i18nFilter('TYPE_TEXT') },
{ id: FilterConditionType.Raw, name: i18nFilter('TYPE_RAW') }
]);
}

View file

@ -29,7 +29,7 @@ class FolderClearPopupView extends AbstractViewPopup {
return folder ? folder.localName() : '';
},
dangerDescHtml: () => i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { 'FOLDER': this.folderNameForClear() })
dangerDescHtml: () => i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: this.folderNameForClear() })
});
decorateKoCommands(this, {

View file

@ -74,13 +74,13 @@ class PluginPopupView extends AbstractViewPopup {
if (isNonEmptyArray(config)) {
this.configures(
config.map(item => ({
'value': ko.observable(item[0]),
'placeholder': ko.observable(item[6]),
'Name': item[1],
'Type': item[2],
'Label': item[3],
'Default': item[4],
'Desc': item[5]
value: ko.observable(item[0]),
placeholder: ko.observable(item[6]),
Name: item[1],
Type: item[2],
Label: item[3],
Default: item[4],
Desc: item[5]
}))
);
}

View file

@ -114,15 +114,15 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
});
// append drag and drop
this.dragOver = ko.observable(false).extend({ 'throttle': 1 });
this.dragOverEnter = ko.observable(false).extend({ 'throttle': 1 });
this.dragOver = ko.observable(false).extend({ throttle: 1 });
this.dragOverEnter = ko.observable(false).extend({ throttle: 1 });
this.sLastSearchValue = '';
this.addComputables({
messageListSearchDesc: () => {
const value = MessageUserStore.listEndSearch();
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : ''
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { SEARCH: value }) : ''
},
messageListPaginator: computedPaginatorHelper(MessageUserStore.listPage,
@ -871,9 +871,9 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
quotaTooltip() {
return i18n('MESSAGE_LIST/QUOTA_SIZE', {
'SIZE': FileInfo.friendlySize(this.userUsageSize()),
'PROC': this.userUsageProc(),
'LIMIT': FileInfo.friendlySize(this.userQuota())
SIZE: FileInfo.friendlySize(this.userUsageSize()),
PROC: this.userUsageProc(),
LIMIT: FileInfo.friendlySize(this.userQuota())
});
}

View file

@ -732,7 +732,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
oMessage.folder,
oMessage.uid,
oMessage.readReceipt(),
i18n('READ_RECEIPT/SUBJECT', { 'SUBJECT': oMessage.subject() }),
i18n('READ_RECEIPT/SUBJECT', { SUBJECT: oMessage.subject() }),
i18n('READ_RECEIPT/BODY', { 'READ-RECEIPT': AccountUserStore.email() })
);