Last active
November 28, 2018 06:59
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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