Skip to content

Instantly share code, notes, and snippets.

@mig82
Last active November 28, 2018 06:59
Show Gist options
  • Save mig82/9caf40339806b665ad8fb2defcc65aa4 to your computer and use it in GitHub Desktop.
Save mig82/9caf40339806b665ad8fb2defcc65aa4 to your computer and use it in GitHub Desktop.
A seminal idea on how to enhance kony.i18n.getLocalizedString with var substitution.
kony.i18n._getLocalizedString = kony.i18n.getLocalizedString;
kony.i18n.getLocalizedString = (key, scope) => {
var s = kony.i18n._getLocalizedString(key);
if(!s) return key;
for (var property in scope) {
if (scope.hasOwnProperty(property)) {
s = s.replace("${" + property + "}", scope[property]);
}
}
return s;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment