mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29: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
|
|
@ -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