META-INF.resources.bower_components.globalize.src.message.formatter-runtime-bind.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
define(function () {
return function (cldr, messageformatter) {
var locale = cldr.locale,
origToString = messageformatter.toString;
messageformatter.toString = function () {
var argNames, argValues, output,
args = {};
// Properly adjust SlexAxton/messageformat.js compiled variables with Globalize variables:
output = origToString.call(messageformatter);
if (/number\(/.test(output)) {
args.number = "messageFormat.number";
}
if (/plural\(/.test(output)) {
args.plural = "messageFormat.plural";
}
if (/select\(/.test(output)) {
args.select = "messageFormat.select";
}
output.replace(/pluralFuncs(\[([^\]]+)\]|\.([a-zA-Z]+))/, function (match) {
args.pluralFuncs = "{" +
"\"" + locale + "\": Globalize(\"" + locale + "\").pluralGenerator()" +
"}";
return match;
});
argNames = Object.keys(args).join(", ");
argValues = Object.keys(args).map(function (key) {
return args[key];
}).join(", ");
return "(function( " + argNames + " ) {\n" +
" return " + output + "\n" +
"})(" + argValues + ")";
};
return messageformatter;
};
});
© 2015 - 2025 Weber Informatics LLC | Privacy Policy