ELECTRON-656 - Correct Japanese translation (#480)

This commit is contained in:
Kiran Niranjan
2018-08-29 10:39:16 +05:30
committed by Vishwas Shashidhar
parent 3306473f07
commit 154b66e195
6 changed files with 45 additions and 22 deletions

22
js/utils/stringFormat.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* Injects content into string
* @param string {String}
* @param data {Object} - content to replace
* @return {*}
*/
function stringFormat(string, data) {
for (let key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
return string.replace(/({([^}]+)})/g, function (i) {
let replacedKey = i.replace(/{/, '').replace(/}/, '');
if (!data[replacedKey]) {
return i;
}
return data[replacedKey];
});
}
}
return null;
}
module.exports = stringFormat;