Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to internationalize a handlebars + backbone view?

I would like to be able to internationalize a backbone + Handlebars application but I am not clear what the best way to do it. Are there any specific best practices for internationalizing backbone + Handlebar views?

On the server side I am using SpringMVC and have access to standard java internationalization facilities.

like image 788
ams Avatar asked Aug 09 '12 13:08

ams


2 Answers

Here are some very good resources on internationalization for the client side.

http://2012.jsconf.eu/speaker/2012/08/28/client-side-internationalization.html really worth watching it provides a good explanation of the issues with internationalization and is java-script focused.

http://alexsexton.com/blog/2012/03/the-ux-of-language/ Good article about the internationalization

JavaScript libraries for internationalization:

  • https://github.com/SlexAxton/messageformat.js
  • http://slexaxton.github.com/Jed/

Standards:

  • http://userguide.icu-project.org/formatparse/messages (very useful read)
  • http://cldr.unicode.org/ (more of a reference)
like image 146
ams Avatar answered Oct 11 '22 18:10

ams


Currently I'm working with an app with (very limited) internationalization, and I mix in an object with the model before sending it to the template in the Backbone.Marionette.Renderer.render function. If you have a similar central function which renders your templates (which I assume you have) you can do this logic there. You could for instance mix the internationalized content (language preselected in) in a namespace, for instance

data = _.extend(model, {t: translations(:dutch))

Leaves how to get the translations from the backend to the frontend, but I don't know enough of SpringMVC to give you advise on that.

like image 22
markijbema Avatar answered Oct 11 '22 18:10

markijbema