Introducing Angular-Translate Quality

For those using Angular JS 1.x, there exist a nice library to deal with internationzalition: Angular-Translate. This library provides a filter, a directive and a service to manage translations. Basically, JS code and HTML templates refer to keys. These keys point to translations located in external files (e.g. JSon files, that will be loaded by the web browser).

You can find more information on the project’s web site.
If this library is quite convenient and does the job, it is however very easy to make mistakes. One can forget a key for some language. Refactoring may miss an item. Inexisting keys might be referenced too. And so on. This is why I created Angular-Translate Quality. The idea is to have a library, used at build time, to verify the correctness of your translation files.

var qual = require('angular-translate-quality');

function cb(msg) {

var valid = qual.validate({
  loc_i18n: './i18n/**/',
  loc_html: './html/**/',
  cb: cb

The library scans HTML files and verifies all the keys used along with the translate filter and directive are defined and are coherent across all the languages. It also provides mechanisms to verify syntax rules for languages (as regular expressions to define). This can be useful to prevent copy/paste errors. The readme provides an extensive documentation about all the options and how to use it. You can see used it in this project. We use it to verify English and French translations in our (Gulp) build process.

About this entry