« Back to blog

New on edge: simplifying i18n

ubiquo_i18n is one of the most used plugins since its inception. This is because the requirement of having a site with contents in more than one language, sharing the contents or not, is pretty common. Given that it is used, is a plugin that has generated a lot of feedback. This week I have pushed a branch that addresses some of the detected annoying points for people.

In the next days I'll highlight some of the most useful new features. Maybe the most important change is for shared associations between translations. Until now they were automatically created in order to ensure that if a model has the locale "en", all the related instances are also in "en". This guaranteed the data consistency in the DB, and also simplified the retrieval process, at the price of complicating the write and update processes. Since reading is usually what one wants to be fast, it looked like a good tradeoff.

But in fact not all this magic was welcome, and the fact that instances are automatically created, and that relations had to be locale-consistent, needed to be taken into account while developing. This has changed.

Now ubiquo_i18n will not create instances by itself. Instead, will rely in Rails associations methods and retrieve the correct relations by locale. The interface for this feature has not changed so there are no changes required in your code because of this. The change you can do to your existing app is to remove the code that manages this kind of situations.

In short, you don't have to worry anymore about in which locale is every instance, ubiquo_i18n will manage this for you. This was what happened before

Note that before, you needed to assign "reader" to "en", and the "ca" reader was automatically created. Now this works as expected:

Hope you like it! It's already on edge, and all the Ubiquo plugins are already profiting this.

 

Comments (0)

Leave a comment...