Rails on the Run

Rails experiments by Matt Aimonetti

Browsing Posts tagged translation

I’m glad to announce a major update of Globalite.

First off I’d like to thank all the translators who helped with this release.

  • Globalite now support its first Asian language: Chinese!
    Ivan Chang did an awesome job creating a localization file in Chinese for Taiwan, Hong Kong and Main Land China. I’m really glad thinking that Globalite will make the Rails experience much nicer for a lot of Chinese people.

  • Ivan also pushed me to add a new feature that people had asked about: a better ActiveRecord error message support.

You know how Rails has a nice way of displaying your Model errors:

AR_error

Well, now that’s automatically translated in your locale. (as long as the new localization files are up to date. Feel free to contact me if you want to improve the locale file in your own language)

  • I also added support for pluralization directly in the translation file. (pluralization doesn’t always make sense in some languages) I’m planning on adding a better Inflector support later on.

for now, in your translation file simply use:

horse_count: we have pluralize{{count}, horse} in the ranch

In your view use the localization with arguments to pass the count:

<%= :horse_count.l_with_args({:count => @horse.count}) %>

See the wiki for more information about pluralization.

  • Finally the demo app has been updated with an example of how to grab the acceptable locale from the header. (thanks to Emmanuel Bouton)

I’m almost ready to update Globalite with 2 major changes:

  • Support for Chinese (Taiwan, Hong Kong and main land China) thanks to Ivan Chang
  • Better support for Active Record error messages in forms (based on contribution from Ivan)

I’m writing more tests and updating the sample app before releasing the updated version. It should be out in the next few days.

[Globalite page @ Google Code](http://code.google.com/p/globalite/

Today I updated Globalite, refactoring the code and fixing some issues.

I added a bunch of aliases since I was tired of typing:

Globalite.current_language = :fr

I shortened it to

Globalite.language = :fr

But the old method is still available so it won’t break your code ;)

The major change with this update is a better support for locales. Let’s say that in our application we setup the language to :fr (French) but we didn’t specify a country. Remember that Globalite lets you have specific translations/localizations per country so you can display dates, prices properly.

Previously, if my locale was set to :fr-* then Globalite would try to load the fr.yml files and not fr-FR.yml.

If you decided to use a fr.yml file for your UI localization, you might have noticed that all the Rails core messages weren’t translated(now you know why). This update deals with this issue and if a translation isn’t found in your locale, it will look for translations in your language but from a different country and pick a random one.

I’m expecting Rails core translations in Japanese, Korean and Chinese. Feel free to email me your own file and let me know on what project you used Globalite.