Blogger.create { :name =>'Matt Aimonetti',
:location => 'San Diego, Ca',
:email => mattaimonetti AT gmail.com,
:linkedin => Matt's Linkedin page,
:recommend_me => HERE,
:contractor => true}

Globalite Major update

Written by matt on September 2nd, 2007

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)


New version of Globalite is coming up

Written by matt on August 29th, 2007

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/



Globalite - usage example

Written by matt on July 2nd, 2007

If you haven't check out the Globalite sample app yet, here are some screenshots.

Here is the French yml file used for the UI translation/localization:

create a yml file with the translation

Here is the code to display a select box so the user can choose the publication date:

write some code to let the user choose a published date

So you know,

<%= :published_date.l %>

is the same as

<%= :published_date.localize %>

Globalite will try to load the translation of the :published_date key using the locale you set. (if you didn't set a locale, it will try in English. If there was no English translation available, a warning message would be displayed instead of the translation. We could have also done the following:

<%= :published_date.l('Published Date') %>

If you pass a string to the localization function, Globalite will display it in the case where it doesn't find a translation.

Here is the default view in English:

let's look at the view in English (default locale)

Change the locale to French ( Locale.code = 'fr-*' or use the select box in the demo app). Let's display the same page:

same date select box in French

Note that in French, the date is different, on top of having translated month names, the order is different. American English format is year/month/day while the French format is day/month/year.

You get all of that for free and even more.

Just for the fun, here is another example of localization: currency. you might know it, but each country, on top of having a different currency display numbers differently.

In the England, it would look like that:

uk

Note that the currency is before the amount and that there's a separator for the thousands and a delimiter for the pence.

In France, it would look like that:

fr

The currency is after the amount and the French separator is actually the British delimiter and vice versa!

Spain also uses the Euro as currency but they don't display the same amount in the same way:

es

The code to display the amount for each locale is the following:

<%= number_to_currency(9999.99) %>

Pretty cool and simple, isn't it? Check out the sample app for more advance used.

Enjoy

p.s: thanks josh knowles for the skitch invite, it's awesome!



Globalite - sample application

Written by matt on July 2nd, 2007

I recently received quite a lot of love because of Globalite. Even though I tried to write some documentation about the plugin, I know that there's not much. I also know that there's a difference between showing how to set a locale and how to actually use that code in a real application.

To fill this gap I wrote a very simple and rough Rails sample application with a fully localized User Interface:

UI Localization sample app

Looking at the code you will find out how to:

  • use a different css per locale (language/country)
  • use a different picture per locale
  • set a default css/picture if the translator doesn't specify one
  • UI localization
  • rails core localization examples
  • create a select box of available UI translations
  • get/set the locale only a specific user so other users start by seeing the default translation
  • use a translation with many dynamic arguments
  • nested translation

note: I froze Edge for this sample app (it wasn't required, Globalite works well with older version of Rails).

To install and run the app, just do the following:

$ svn checkout http://globalite.googlecode.com/svn/sample/ui globalite-sample-app

edit config/database.example and rename it config/database.yml

$ rake db:create

$ rake db:migrate

$ ruby script/server

Don't hesitate to leave a comment, submit a Rails core localization file in your language or submit a bug



Globalite update

Written by matt on June 27th, 2007

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.



Você fala português?

Written by matt on June 25th, 2007

Globalite contributor: Marcus Derencius just submitted a Portuguese translation for Rails.

Your application can now speak Portuguese thanks to Globalite and Marcus :)



Globalite new built-in language: Italian

Written by matt on June 12th, 2007

Globalite now has built-in support for the following languages:

  • English (UK)
  • English (US)
  • French (France)
  • Spanish (Generic)
  • Italian

I'm planning on adding support for more languages, but if you want to help me, please email me your language yaml file. Don't forget to mention the full locale (language + country) of the translation.

Database content is coming soon... as soon as I can find some time to hack on this project.

Just a reminder:

script/plugin install http://globalite.googlecode.com/svn/trunk/

and rename the trunk folder globalite

or svn checkout in the plugin folder:

svn checkout http://globalite.googlecode.com/svn/trunk/ globalite


Globalite has moved

Written by matt on May 31st, 2007

I’ve been struggling with finding a good place to host my Globalite Rails plugin. After trying rubyForge and then hosting the plugin myself

I finally decided to move the project to Google code

install the plugin:

script/plugin install http://globalite.googlecode.com/svn/trunk/

rename the vendor/plugins/trunk => vendor/plugins/globalite or from your vendor/plugins folder:

svn checkout http://globalite.googlecode.com/svn/trunk/ globalite

Feel free to report issues there or to submit patches.



Globalite or another i18n/l10n solution

Written by matt on May 15th, 2007

I've been recently slightly annoyed by the lack of simple yet powerful internationalization/localization plugin for Rails. It seems like the only real solution out there is Globalize

However, it's a heavy, bloated, hard to setup plugin. I might seem to complain, but I'm actually glad that someone came up with a decent solution. Globalize is quite powerful but I would like to see something simpler, lighter and easier to use.

While I was looking for alternate solutions, Err released Gibberish a simple and nice localization plugin.

Looking at Chris' code, I found a clean and nice solution but unfortunately too simple. The major problem I had with Giberrish was the lack of support for locales. That means that one cannot create an application supporting British English and American English. I lived in both America and the UK and believe me, I can never spell some words properly. How should I spell the following words: colours or colors, behaviour or behavior, aluminium or aluminum? On top of that, your UI might be slightly different based on the region your visitor is coming from. Localization is more than translation.

Anyway, I decided to come up with my own solution, a breed of the best features from my favorite i18n/l10n projects. This hybrid solution should, hopefully be useful for people not needing all the resources of Globalize. I called my new project Globa_lite_

What's cool with Globalite?

  • Simple UI localization

    • support different locales
    • yml file based
    • simple syntax
    • no setup needed
    • enough for most projects needing localization
    • pass variables to the localization and let the translator deal with it
  • Simple Rails Localization

    • support different locales
    • nothing to do, rails comes in your own language (including currency conversion and other helpers)
    • yml file based localization for easy update
    • support for Rails 1.2x
    • simple to maintain
    • simple to add/edit a new locale
  • Simple content i18n/l10n (coming soon)

UI localization:

  • Create a lang/ui folder at the root of the folder.
  • create 2 localization files: fr.yml and en-US.yml
  • add localization keys in the files:

fr.yml:

hello: bonjour

welcome: bienvenue

en-US.yml

hello: howdy

welcome: welcome
  • Declare the current locale or language

    Globalite.current_language :fr
    
  • In your view (or anywhere else) localize a key

    :hello.l
    

or

:hello.localize

you can also do

:unknown_key.l("this is the default text to display if the localization isn't found")

Also you can pass one or many variables to the localization(check the documentation)

Rails Localization

Rails is automatically localized for you (meaning most helpers, including the currency converter are localized for the locale you declared). You really easily add a new supported rails language/settings by adding a yml file or editing an existing one. (for now, I only create an English and a French localization file, but I'll add plenty more very soon)

Globalite also saves the locale in the session allowing many users to see a site at the same time in different languages :)

I believe Globalite is/will be a good solution for most of my international projects. It still lacks the content i18n and l10n as well as support for pluralization but it should be added soon.

Give it a try and let me know what you think:

RubyForge page

svn repository: svn checkout svn://rubyforge.org/var/svn/globalite/trunk globalite

view repository content

ps: The project is still in beta and will change during the next few weeks, feel free to submit patches, ideas, suggestions...