mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Upgrade i18n() to use Object.entries()
And replace quoted object keys to be without quotes
This commit is contained in:
parent
fe4dbc729c
commit
7eaaa0a793
24 changed files with 224 additions and 231 deletions
|
|
@ -11,96 +11,96 @@ const
|
|||
sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'],
|
||||
|
||||
exts = {
|
||||
'eml': 'message/rfc822',
|
||||
'mime': 'message/rfc822',
|
||||
'rtx': 'text/richtext',
|
||||
'vcard': 'text/vcard',
|
||||
'vcf': 'text/vcard',
|
||||
'htm': 'text/html',
|
||||
'html': 'text/html',
|
||||
'csv': 'text/csv',
|
||||
'ics': 'text/calendar',
|
||||
'ifb': 'text/calendar',
|
||||
'xml': 'text/xml',
|
||||
'json': app+'json',
|
||||
'p10': app+'pkcs10',
|
||||
'p7c': app+'pkcs7-mime',
|
||||
'p7m': app+'pkcs7-mime',
|
||||
'p7s': app+'pkcs7-signature',
|
||||
'torrent': app+'x-bittorrent',
|
||||
eml: 'message/rfc822',
|
||||
mime: 'message/rfc822',
|
||||
rtx: 'text/richtext',
|
||||
vcard: 'text/vcard',
|
||||
vcf: 'text/vcard',
|
||||
htm: 'text/html',
|
||||
html: 'text/html',
|
||||
csv: 'text/csv',
|
||||
ics: 'text/calendar',
|
||||
ifb: 'text/calendar',
|
||||
xml: 'text/xml',
|
||||
json: app+'json',
|
||||
p10: app+'pkcs10',
|
||||
p7c: app+'pkcs7-mime',
|
||||
p7m: app+'pkcs7-mime',
|
||||
p7s: app+'pkcs7-signature',
|
||||
torrent: app+'x-bittorrent',
|
||||
|
||||
// scripts
|
||||
'js': app+'javascript',
|
||||
'pl': 'text/perl',
|
||||
'css': 'text/css',
|
||||
'asp': 'text/asp',
|
||||
'php': app+'x-httpd-php',
|
||||
'phtml': app+'x-httpd-php',
|
||||
js: app+'javascript',
|
||||
pl: 'text/perl',
|
||||
css: 'text/css',
|
||||
asp: 'text/asp',
|
||||
php: app+'x-httpd-php',
|
||||
phtml: app+'x-httpd-php',
|
||||
|
||||
// images
|
||||
'jpg': 'image/jpeg',
|
||||
'ico': 'image/x-icon',
|
||||
'tif': 'image/tiff',
|
||||
'svg': 'image/svg+xml',
|
||||
'svgz': 'image/svg+xml',
|
||||
jpg: 'image/jpeg',
|
||||
ico: 'image/x-icon',
|
||||
tif: 'image/tiff',
|
||||
svg: 'image/svg+xml',
|
||||
svgz: 'image/svg+xml',
|
||||
|
||||
// archives
|
||||
'zip': app+'zip',
|
||||
zip: app+'zip',
|
||||
'7z': app+'x-7z-compressed',
|
||||
'rar': app+'x-rar-compressed',
|
||||
'cab': app+'vnd.ms-cab-compressed',
|
||||
'gz': app+'x-gzip',
|
||||
'tgz': app+'x-gzip',
|
||||
'bz': app+'x-bzip',
|
||||
'bz2': app+'x-bzip2',
|
||||
'deb': app+'x-debian-package',
|
||||
rar: app+'x-rar-compressed',
|
||||
cab: app+'vnd.ms-cab-compressed',
|
||||
gz: app+'x-gzip',
|
||||
tgz: app+'x-gzip',
|
||||
bz: app+'x-bzip',
|
||||
bz2: app+'x-bzip2',
|
||||
deb: app+'x-debian-package',
|
||||
|
||||
// audio
|
||||
'mp3': 'audio/mpeg',
|
||||
'wav': 'audio/x-wav',
|
||||
'mp4a': 'audio/mp4',
|
||||
'weba': 'audio/webm',
|
||||
'm3u': 'audio/x-mpegurl',
|
||||
mp3: 'audio/mpeg',
|
||||
wav: 'audio/x-wav',
|
||||
mp4a: 'audio/mp4',
|
||||
weba: 'audio/webm',
|
||||
m3u: 'audio/x-mpegurl',
|
||||
|
||||
// video
|
||||
'qt': 'video/quicktime',
|
||||
'mov': 'video/quicktime',
|
||||
'wmv': 'video/windows-media',
|
||||
'avi': 'video/x-msvideo',
|
||||
qt: 'video/quicktime',
|
||||
mov: 'video/quicktime',
|
||||
wmv: 'video/windows-media',
|
||||
avi: 'video/x-msvideo',
|
||||
'3gp': 'video/3gpp',
|
||||
'3g2': 'video/3gpp2',
|
||||
'mp4v': 'video/mp4',
|
||||
'mpg4': 'video/mp4',
|
||||
'ogv': 'video/ogg',
|
||||
'm4v': 'video/x-m4v',
|
||||
'asf': 'video/x-ms-asf',
|
||||
'asx': 'video/x-ms-asf',
|
||||
'wm': 'video/x-ms-wm',
|
||||
'wmx': 'video/x-ms-wmx',
|
||||
'wvx': 'video/x-ms-wvx',
|
||||
'movie': 'video/x-sgi-movie',
|
||||
mp4v: 'video/mp4',
|
||||
mpg4: 'video/mp4',
|
||||
ogv: 'video/ogg',
|
||||
m4v: 'video/x-m4v',
|
||||
asf: 'video/x-ms-asf',
|
||||
asx: 'video/x-ms-asf',
|
||||
wm: 'video/x-ms-wm',
|
||||
wmx: 'video/x-ms-wmx',
|
||||
wvx: 'video/x-ms-wvx',
|
||||
movie: 'video/x-sgi-movie',
|
||||
|
||||
// adobe
|
||||
'pdf': app+'pdf',
|
||||
'psd': 'image/vnd.adobe.photoshop',
|
||||
'ai': app+'postscript',
|
||||
'eps': app+'postscript',
|
||||
'ps': app+'postscript',
|
||||
pdf: app+'pdf',
|
||||
psd: 'image/vnd.adobe.photoshop',
|
||||
ai: app+'postscript',
|
||||
eps: app+'postscript',
|
||||
ps: app+'postscript',
|
||||
|
||||
// ms office
|
||||
'doc': app+'msword',
|
||||
'rtf': app+'rtf',
|
||||
'xls': app+'vnd.ms-excel',
|
||||
'ppt': app+'vnd.ms-powerpoint',
|
||||
'docx': msOffice+'wordprocessingml.document',
|
||||
'xlsx': msOffice+'spreadsheetml.sheet',
|
||||
'dotx': msOffice+'wordprocessingml.template',
|
||||
'pptx': msOffice+'presentationml.presentation',
|
||||
doc: app+'msword',
|
||||
rtf: app+'rtf',
|
||||
xls: app+'vnd.ms-excel',
|
||||
ppt: app+'vnd.ms-powerpoint',
|
||||
docx: msOffice+'wordprocessingml.document',
|
||||
xlsx: msOffice+'spreadsheetml.sheet',
|
||||
dotx: msOffice+'wordprocessingml.template',
|
||||
pptx: msOffice+'presentationml.presentation',
|
||||
|
||||
// open office
|
||||
'odt': openDoc+'text',
|
||||
'ods': openDoc+'spreadsheet',
|
||||
'odp': openDoc+'presentation'
|
||||
odt: openDoc+'text',
|
||||
ods: openDoc+'spreadsheet',
|
||||
odp: openDoc+'presentation'
|
||||
};
|
||||
|
||||
export const FileType = {
|
||||
|
|
|
|||
|
|
@ -14,19 +14,12 @@ export const trigger = ko.observable(false);
|
|||
* @returns {string}
|
||||
*/
|
||||
export function i18n(key, valueList, defaulValue) {
|
||||
let valueName = '',
|
||||
result = I18N_DATA[key];
|
||||
let result = I18N_DATA[key] || defaulValue || key;
|
||||
|
||||
if (undefined === result) {
|
||||
result = undefined === defaulValue ? key : defaulValue;
|
||||
}
|
||||
|
||||
if (null != valueList) {
|
||||
for (valueName in valueList) {
|
||||
if (Object.prototype.hasOwnProperty.call(valueList, valueName)) {
|
||||
result = result.replace('%' + valueName + '%', valueList[valueName]);
|
||||
}
|
||||
}
|
||||
if (valueList) {
|
||||
Object.entries(valueList).forEach(([key, value]) => {
|
||||
result = result.replace('%' + key + '%', value);
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue