angular-gettext - Effortless translation support for Angular.JS

Recently I’ve had to add translation support to an Angular.JS application. There’s a couple of modules around that can help you with that, but none of them felt right. Either they force you to use key/value mappings (cumbersome) or they have a very painful, broken system for plurals.

I wanted something that is:

  • Trivial to use
  • Doesn’t take any of the nice aspects of Angular.JS away from me.

Enter angular-gettext.
I’ve always been a fan of gettext, which is used extensively in the GNOME project, now there’s an MIT-licensed Angular.JS implementation.

Translating a web application with angular-gettext is as simple as adding an attribute:

<a href="/" translate>Hello {{name}}</a>

This, together with a small library and some Grunt tasks allows you to open your app up to any language you want. Interpolation just keeps working and there’s support for plurals.

There’s lots of documentation on the website, have a look at it if you want to go global:

Posted: September 24, 2013 21:03 Tags: angular