I have a list of i18n translation strings within an meteor-i18n object that I'm iterating over. Instead of creating a Template Helper for each string manually though, which would soon become redundant and repetitive, I would like to create the Helpers dynamically, within a loop, like so:
for (var namespace in Meteor.i18nMessages) {
for (var msg in Meteor.i18nMessages[namespace]){
//Template[namespace][msg] = __(namespace + "." + msg); // <- works but is not reactive
Template[namespace][msg] = function() { // <- Doesn't work: always returns last value from object
return __(namespace + "." + msg);
}
}
}
However when I do, I lose reactivity. How would one go about solving this? I'm a fan of best-practices and elegant code.
Thanks.