mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-656 - Correct Japanese translation (#480)
This commit is contained in:
committed by
Vishwas Shashidhar
parent
3306473f07
commit
154b66e195
22
js/utils/stringFormat.js
Normal file
22
js/utils/stringFormat.js
Normal 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;
|
||||
Reference in New Issue
Block a user