Skip to content

Instantly share code, notes, and snippets.

@Fintan
Created September 6, 2013 16:43
Show Gist options
  • Save Fintan/6466424 to your computer and use it in GitHub Desktop.
Save Fintan/6466424 to your computer and use it in GitHub Desktop.
Internationalising a Marionette application
//Support for internationalisation - beginning
//filter strings with 'Interp' in name and register them as partials
_.each(Strings, function(str, key) {
if(key.indexOf('Interp') > -1) {
Handlebars.registerPartial(key.substr(0, key.indexOf('Interp')), str);
}
});
Backbone.Marionette.ItemView.prototype.serializeData = _.wrap(Backbone.Marionette.ItemView.prototype.serializeData, function(_serializeData) {
return _.extend(_serializeData.apply(this, arguments), Strings);
});
//internationalisation support - end
define({
"root": {
"red": "red",
"blue": "blue",
"green": "green",
"yellow": "yellow",
"greetingInterp": "hello {{profileId}}, how's it going?",
"greeting2Interp": "hello, how's it going {{profileId}}?"
},
"fr-fr": true
});
{{!profileId will be part of the existing data that is passed}}
<br />
{{red}} | {{green}} | {{blue}} | {{yellow}}
<br />
{{> greeting}}
<br />
{{> greeting2}}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment