Multilingual Data Structures
Localisation is hard work. The data structures are much more complicated and there is much more work involved in getting the thing to work.
At the root of the problem of localistion and multi-lingual systems however, is how to store the data in the first place. Which is the best way to represent or model the data in a database so that writing the classes and accessing the data is as easy as possible? Translated data is really an extension to object data, as you aren’t really adding anything new about the object in question, however to store it correctly and maintain a level of scaleability (support for many translations) you need to have more than one table; this breaks the Ruby on Rails “Table row => Object” paradigm.
Ruby on Rails has many separate projects for the localisation of RoR applications, but very little in the way of the data structures and models. One example I found that does delve into models is the [Globalize Plugin](http://www.globalize-rails.org/globalize/), it appears to have excellent support for the general translation of the project (useful bits for dates and numbers), but uses the same system for the translation of content, i.e. each record has a translation which is stored in the system wide translation table.
This appears to be the general pattern which while suitable for a lot of situations, my current situation requires something more “data centric” rather than user interface orientated.
After being influenced by Multilingual Support for Web Applications, I’ve decided the best approach for the moment will be to write a structure based on default values, stored in a normal object, and optional language specific data, stuck on in the form of child objects. This allows me to maintain the basic structure, but it is not quite as clean to access object data and will require some extra accessor functions to access the child object translations transparently. Perhaps this can be programmed into rails as a plugin so I don’t need to define each accessor individually…
I’ll update this as soon as I have a basic implementation in place.
No comments yet