views:

250

answers:

2

I want to have Greek support in my rails app for the messages/flashes etc. I took a quick look at the I18n framework but it seems like a lot of configuration for something so simple. I thing that there should be a very easy way to do something like this but ( apparently ) I don't know it. If anyone would be willing to help me I'll be glad. Thanks.

A: 

I18N ain't simple.

Here are some of the reasons why internationalization is hard.

First, every piece of text that might be shown to the user is a potential candidate for translation. That means not just properties of components (like menu items and button labels), but also text drawn with stroke drawing calls, and text embedded in pixel images (like this one taken from the MIT EECS web page). Translation can easily change the size or aspect ratio of the text; German labels tend to be much longer than English ones, for example.

Error messages also need to be translated, of course — which is another reason not to expose internal system names in error messages. An English-reading user might be able to figure out what FileNotFoundException means, but it won’t internationalize well.

Don't know Ruby so I can't help you more.

voyager
+1  A: 

Rails has conventions so you don't have to configure.

Create a file in config/locales/el.yml with the contents:

el:
  flash_messages:
    success: "επιτυχία"
    fail: "αποτυγχάνουν"

Then in your controller:

flash[:notice] = t('flash_messages.success')

and you'll get the translated string in your view.

You can change the locale like this:

I18n.locale = :el

I don't know how it could be easier. The "Rails I18n Guide":http://guides.rubyonrails.org/i18n.html has all the gory details if you want to fight the conventions or go beyond simple.

eremite