I'm still trying to bind to translated text in a table cell.
jQuery.i18n.properties({
name: 'Terms',
path: 'trans/',
mode: 'map',
cache: 'true',
callback: function () {
console.log("Loaded i18n file...");
// Accessing a value with placeholders through the map
console.log(jQuery.i18n.prop('MYKEY'));
}
});
So I see the translated text in the console log. All good.
I bind my table cell data inside a Template:
<td data-bind="i18nTranslateText: printConditionDetails().name">LABEL_PRINT_CONDITION</td>
I use koExternalTemplateEngine to load the template. All good so far.
I created a custom binding like this:
ko.bindingHandlers.i18nTranslateText = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var param1 = valueAccessor(); // not used, but could be used.
var key = $(element).text();
$(element).html(jQuery.i18n.prop(key));
},
update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
// At this point your language have change, update all labels
}
};
But for some reason, jQuery.i18n is "undefined". I think it's some sort of namespace/scope issue but I can't get a handle on it.
jQuery.i18n variable was initialized but when the custom binding is triggered, jQuery.18n becomes "undefined".
Anyone knows why and can guide me to how to fix this?
Thanx in advance,
Lesli