Skip to content

Commit 7eaaa0a

Browse files
author
djmaze
committed
Upgrade i18n() to use Object.entries()
And replace quoted object keys to be without quotes
1 parent fe4dbc7 commit 7eaaa0a

File tree

24 files changed

+224
-231
lines changed

24 files changed

+224
-231
lines changed

dev/Common/File.js

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,96 +11,96 @@ const
1111
sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'],
1212

1313
exts = {
14-
'eml': 'message/rfc822',
15-
'mime': 'message/rfc822',
16-
'rtx': 'text/richtext',
17-
'vcard': 'text/vcard',
18-
'vcf': 'text/vcard',
19-
'htm': 'text/html',
20-
'html': 'text/html',
21-
'csv': 'text/csv',
22-
'ics': 'text/calendar',
23-
'ifb': 'text/calendar',
24-
'xml': 'text/xml',
25-
'json': app+'json',
26-
'p10': app+'pkcs10',
27-
'p7c': app+'pkcs7-mime',
28-
'p7m': app+'pkcs7-mime',
29-
'p7s': app+'pkcs7-signature',
30-
'torrent': app+'x-bittorrent',
14+
eml: 'message/rfc822',
15+
mime: 'message/rfc822',
16+
rtx: 'text/richtext',
17+
vcard: 'text/vcard',
18+
vcf: 'text/vcard',
19+
htm: 'text/html',
20+
html: 'text/html',
21+
csv: 'text/csv',
22+
ics: 'text/calendar',
23+
ifb: 'text/calendar',
24+
xml: 'text/xml',
25+
json: app+'json',
26+
p10: app+'pkcs10',
27+
p7c: app+'pkcs7-mime',
28+
p7m: app+'pkcs7-mime',
29+
p7s: app+'pkcs7-signature',
30+
torrent: app+'x-bittorrent',
3131

3232
// scripts
33-
'js': app+'javascript',
34-
'pl': 'text/perl',
35-
'css': 'text/css',
36-
'asp': 'text/asp',
37-
'php': app+'x-httpd-php',
38-
'phtml': app+'x-httpd-php',
33+
js: app+'javascript',
34+
pl: 'text/perl',
35+
css: 'text/css',
36+
asp: 'text/asp',
37+
php: app+'x-httpd-php',
38+
phtml: app+'x-httpd-php',
3939

4040
// images
41-
'jpg': 'image/jpeg',
42-
'ico': 'image/x-icon',
43-
'tif': 'image/tiff',
44-
'svg': 'image/svg+xml',
45-
'svgz': 'image/svg+xml',
41+
jpg: 'image/jpeg',
42+
ico: 'image/x-icon',
43+
tif: 'image/tiff',
44+
svg: 'image/svg+xml',
45+
svgz: 'image/svg+xml',
4646

4747
// archives
48-
'zip': app+'zip',
48+
zip: app+'zip',
4949
'7z': app+'x-7z-compressed',
50-
'rar': app+'x-rar-compressed',
51-
'cab': app+'vnd.ms-cab-compressed',
52-
'gz': app+'x-gzip',
53-
'tgz': app+'x-gzip',
54-
'bz': app+'x-bzip',
55-
'bz2': app+'x-bzip2',
56-
'deb': app+'x-debian-package',
50+
rar: app+'x-rar-compressed',
51+
cab: app+'vnd.ms-cab-compressed',
52+
gz: app+'x-gzip',
53+
tgz: app+'x-gzip',
54+
bz: app+'x-bzip',
55+
bz2: app+'x-bzip2',
56+
deb: app+'x-debian-package',
5757

5858
// audio
59-
'mp3': 'audio/mpeg',
60-
'wav': 'audio/x-wav',
61-
'mp4a': 'audio/mp4',
62-
'weba': 'audio/webm',
63-
'm3u': 'audio/x-mpegurl',
59+
mp3: 'audio/mpeg',
60+
wav: 'audio/x-wav',
61+
mp4a: 'audio/mp4',
62+
weba: 'audio/webm',
63+
m3u: 'audio/x-mpegurl',
6464

6565
// video
66-
'qt': 'video/quicktime',
67-
'mov': 'video/quicktime',
68-
'wmv': 'video/windows-media',
69-
'avi': 'video/x-msvideo',
66+
qt: 'video/quicktime',
67+
mov: 'video/quicktime',
68+
wmv: 'video/windows-media',
69+
avi: 'video/x-msvideo',
7070
'3gp': 'video/3gpp',
7171
'3g2': 'video/3gpp2',
72-
'mp4v': 'video/mp4',
73-
'mpg4': 'video/mp4',
74-
'ogv': 'video/ogg',
75-
'm4v': 'video/x-m4v',
76-
'asf': 'video/x-ms-asf',
77-
'asx': 'video/x-ms-asf',
78-
'wm': 'video/x-ms-wm',
79-
'wmx': 'video/x-ms-wmx',
80-
'wvx': 'video/x-ms-wvx',
81-
'movie': 'video/x-sgi-movie',
72+
mp4v: 'video/mp4',
73+
mpg4: 'video/mp4',
74+
ogv: 'video/ogg',
75+
m4v: 'video/x-m4v',
76+
asf: 'video/x-ms-asf',
77+
asx: 'video/x-ms-asf',
78+
wm: 'video/x-ms-wm',
79+
wmx: 'video/x-ms-wmx',
80+
wvx: 'video/x-ms-wvx',
81+
movie: 'video/x-sgi-movie',
8282

8383
// adobe
84-
'pdf': app+'pdf',
85-
'psd': 'image/vnd.adobe.photoshop',
86-
'ai': app+'postscript',
87-
'eps': app+'postscript',
88-
'ps': app+'postscript',
84+
pdf: app+'pdf',
85+
psd: 'image/vnd.adobe.photoshop',
86+
ai: app+'postscript',
87+
eps: app+'postscript',
88+
ps: app+'postscript',
8989

9090
// ms office
91-
'doc': app+'msword',
92-
'rtf': app+'rtf',
93-
'xls': app+'vnd.ms-excel',
94-
'ppt': app+'vnd.ms-powerpoint',
95-
'docx': msOffice+'wordprocessingml.document',
96-
'xlsx': msOffice+'spreadsheetml.sheet',
97-
'dotx': msOffice+'wordprocessingml.template',
98-
'pptx': msOffice+'presentationml.presentation',
91+
doc: app+'msword',
92+
rtf: app+'rtf',
93+
xls: app+'vnd.ms-excel',
94+
ppt: app+'vnd.ms-powerpoint',
95+
docx: msOffice+'wordprocessingml.document',
96+
xlsx: msOffice+'spreadsheetml.sheet',
97+
dotx: msOffice+'wordprocessingml.template',
98+
pptx: msOffice+'presentationml.presentation',
9999

100100
// open office
101-
'odt': openDoc+'text',
102-
'ods': openDoc+'spreadsheet',
103-
'odp': openDoc+'presentation'
101+
odt: openDoc+'text',
102+
ods: openDoc+'spreadsheet',
103+
odp: openDoc+'presentation'
104104
};
105105

106106
export const FileType = {

dev/Common/Translator.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,12 @@ export const trigger = ko.observable(false);
1414
* @returns {string}
1515
*/
1616
export function i18n(key, valueList, defaulValue) {
17-
let valueName = '',
18-
result = I18N_DATA[key];
17+
let result = I18N_DATA[key] || defaulValue || key;
1918

20-
if (undefined === result) {
21-
result = undefined === defaulValue ? key : defaulValue;
22-
}
23-
24-
if (null != valueList) {
25-
for (valueName in valueList) {
26-
if (Object.prototype.hasOwnProperty.call(valueList, valueName)) {
27-
result = result.replace('%' + valueName + '%', valueList[valueName]);
28-
}
29-
}
19+
if (valueList) {
20+
Object.entries(valueList).forEach(([key, value]) => {
21+
result = result.replace('%' + key + '%', value);
22+
});
3023
}
3124

3225
return result;

dev/Model/Message.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,22 +272,22 @@ export class MessageModel extends AbstractModel {
272272
lineAsCss() {
273273
let classes = [];
274274
Object.entries({
275-
'deleted': this.deleted(),
275+
deleted: this.deleted(),
276276
'deleted-mark': this.isDeleted(),
277-
'selected': this.selected(),
278-
'checked': this.checked(),
279-
'flagged': this.isFlagged(),
280-
'unseen': this.isUnseen(),
281-
'answered': this.isAnswered(),
282-
'forwarded': this.isForwarded(),
283-
'focused': this.focused(),
284-
'important': this.isImportant(),
285-
'withAttachments': this.hasAttachments(),
286-
'new': this.newForAnimation(),
287-
'emptySubject': !this.subject(),
288-
// 'hasChildrenMessage': 1 < this.threadsLen(),
289-
'hasUnseenSubMessage': this.hasUnseenSubMessage(),
290-
'hasFlaggedSubMessage': this.hasFlaggedSubMessage()
277+
selected: this.selected(),
278+
checked: this.checked(),
279+
flagged: this.isFlagged(),
280+
unseen: this.isUnseen(),
281+
answered: this.isAnswered(),
282+
forwarded: this.isForwarded(),
283+
focused: this.focused(),
284+
important: this.isImportant(),
285+
withAttachments: this.hasAttachments(),
286+
new: this.newForAnimation(),
287+
emptySubject: !this.subject(),
288+
// hasChildrenMessage: 1 < this.threadsLen(),
289+
hasUnseenSubMessage: this.hasUnseenSubMessage(),
290+
hasFlaggedSubMessage: this.hasFlaggedSubMessage()
291291
}).forEach(([key, value]) => value && classes.push(key));
292292
return classes.join(' ');
293293
}

dev/Remote/AbstractFetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class AbstractFetchRemote
162162
*/
163163
jsVersion(fCallback, sVersion) {
164164
this.defaultRequest(fCallback, 'Version', {
165-
'Version': sVersion
165+
Version: sVersion
166166
});
167167
}
168168

dev/Settings/Admin/Branding.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ export class BrandingAdminSettings {
1313

1414
this.title.subscribe(value =>
1515
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.title.trigger, this), {
16-
'Title': value.trim()
16+
Title: value.trim()
1717
})
1818
);
1919

2020
this.loadingDesc.subscribe(value =>
2121
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.loadingDesc.trigger, this), {
22-
'LoadingDescription': value.trim()
22+
LoadingDescription: value.trim()
2323
})
2424
);
2525

2626
this.faviconUrl.subscribe(value =>
2727
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.faviconUrl.trigger, this), {
28-
'FaviconUrl': value.trim()
28+
FaviconUrl: value.trim()
2929
})
3030
);
3131
}

dev/Settings/Admin/Contacts.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,36 @@ export class ContactsAdminSettings {
7474
addSubscribablesTo(this, {
7575
enableContacts: value =>
7676
Remote.saveAdminConfig(null, {
77-
'ContactsEnable': value ? 1 : 0
77+
ContactsEnable: value ? 1 : 0
7878
}),
7979

8080
contactsSync: value =>
8181
Remote.saveAdminConfig(null, {
82-
'ContactsSync': value ? 1 : 0
82+
ContactsSync: value ? 1 : 0
8383
}),
8484

8585
contactsType: value => {
8686
this.testContactsSuccess(false);
8787
this.testContactsError(false);
8888
this.testContactsErrorMessage('');
8989
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this), {
90-
'ContactsPdoType': value.trim()
90+
ContactsPdoType: value.trim()
9191
})
9292
},
9393

9494
pdoDsn: value =>
9595
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this), {
96-
'ContactsPdoDsn': value.trim()
96+
ContactsPdoDsn: value.trim()
9797
}),
9898

9999
pdoUser: value =>
100100
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this), {
101-
'ContactsPdoUser': value.trim()
101+
ContactsPdoUser: value.trim()
102102
}),
103103

104104
pdoPassword: value =>
105105
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this), {
106-
'ContactsPdoPassword': value.trim()
106+
ContactsPdoPassword: value.trim()
107107
})
108108
})
109109

@@ -121,10 +121,10 @@ export class ContactsAdminSettings {
121121
this.testing(true);
122122

123123
Remote.testContacts(this.onTestContactsResponse, {
124-
'ContactsPdoType': this.contactsType(),
125-
'ContactsPdoDsn': this.pdoDsn(),
126-
'ContactsPdoUser': this.pdoUser(),
127-
'ContactsPdoPassword': this.pdoPassword()
124+
ContactsPdoType: this.contactsType(),
125+
ContactsPdoDsn: this.pdoDsn(),
126+
ContactsPdoUser: this.pdoUser(),
127+
ContactsPdoPassword: this.pdoPassword()
128128
});
129129
}
130130

dev/Settings/Admin/General.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ export class GeneralAdminSettings {
9393
addSubscribablesTo(this, {
9494
mainAttachmentLimit: value =>
9595
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this), {
96-
'AttachmentLimit': pInt(value)
96+
AttachmentLimit: pInt(value)
9797
}),
9898

9999
language: value =>
100100
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.languageTrigger, this), {
101-
'Language': value.trim()
101+
Language: value.trim()
102102
}),
103103

104104
languageAdmin: value => {
105105
this.languageAdminTrigger(SaveSettingsStep.Animate);
106106
translatorReload(true, value)
107107
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
108108
.then(() => Remote.saveAdminConfig(null, {
109-
'LanguageAdmin': value.trim()
109+
LanguageAdmin: value.trim()
110110
}));
111111
},
112112

113113
theme: value => {
114114
changeTheme(value, this.themeTrigger);
115115
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.themeTrigger, this), {
116-
'Theme': value.trim()
116+
Theme: value.trim()
117117
});
118118
},
119119

dev/Settings/Admin/Login.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ export class LoginAdminSettings {
1919
addSubscribablesTo(this, {
2020
determineUserLanguage: value =>
2121
Remote.saveAdminConfig(null, {
22-
'DetermineUserLanguage': value ? 1 : 0
22+
DetermineUserLanguage: value ? 1 : 0
2323
}),
2424

2525
determineUserDomain: value =>
2626
Remote.saveAdminConfig(null, {
27-
'DetermineUserDomain': value ? 1 : 0
27+
DetermineUserDomain: value ? 1 : 0
2828
}),
2929

3030
allowLanguagesOnLogin: value =>
3131
Remote.saveAdminConfig(null, {
32-
'AllowLanguagesOnLogin': value ? 1 : 0
32+
AllowLanguagesOnLogin: value ? 1 : 0
3333
}),
3434

3535
hideSubmitButton: value =>
3636
Remote.saveAdminConfig(null, {
37-
'hideSubmitButton': value ? 1 : 0
37+
hideSubmitButton: value ? 1 : 0
3838
}),
3939

4040
defaultDomain: value =>
4141
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.defaultDomain.trigger, this), {
42-
'LoginDefaultDomain': value.trim()
42+
LoginDefaultDomain: value.trim()
4343
})
4444
});
4545
}

dev/Settings/Admin/Plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class PluginsAdminSettings {
2424

2525
this.enabledPlugins.subscribe(value =>
2626
Remote.saveAdminConfig(null, {
27-
'EnabledPlugins': value ? 1 : 0
27+
EnabledPlugins: value ? 1 : 0
2828
})
2929
);
3030
}

0 commit comments

Comments
 (0)