I18n Editor – Editing those pesky YAML files in Rails Apps

I am currently working on a rewrite of a .NET web application into Rails for a client based in the US.

The original application used .NET globalization files (in short, resource files) for providing translations of labels etc into other languages – and well, there’s no sense in throwing all the hard work of translation away, so first things first I wrote a script to transform the RESX files into YAML files.

The script its self is pretty simple – look at the source directory and grab all the .resx files, infer (from the filename) the language of the file and the target file (e.g. if the file is called UserProfile.es.resx then the language is es and the target file is UserProfile.yaml), then using Hpricot do some XPath queries and pump out some YAML.

So now I have the files ready to go into the Rails app, and everything tests out fine – total time.. 1-2 hours (tweaking and testing takes time).

There is a slight problem though – translations are split into their language groups, and into file groups, so working with these files (i.e. adding a new translation, renaming a key etc) becomes problematic – its a very manual process, and very prone to errors. In order to fix this I did what a developer would do – write a tool for it.

Introducing I18n Editor (sources available at http://github.com/amasses/I18n-Editor/tree/master) – a nifty little Rails all which reads in your I18n YAML files and provides you with manipulation goodness. While the UI is far from pretty it is functional, and it allows me to very easily open a group of I18n files and manipulate the content very easily – including renaming the translation key (across several files at once!).

The tool is lacking support for certain features at the moment, such as scopes/nesting – and it uses en as the primary translation language – but these things happen in small steps. To be honest I’m actually surprised that I was able to build something like this in the space of 5 hours (yes, it was a very boring Saturday night/Sunday morning…).

The sources for the tool are available online via GitHub, and they are licensed Creative Commons Share-Alike (so in short, attribute me as the original creator, and if you make changes please be nice and share them!), so feel free to download and play around with it.

  • http://www.lingui.st/ Thomas

    The NetBeans YAML editor does also a good job. Maybe you should have a look at it.

  • http://www.lingui.st/ Thomas

    The NetBeans YAML editor does also a good job. Maybe you should have a look at it.