Archive for September, 2006

Translate Your Rails Application.

Gettext is a great tool for translating user interfaces of applications into different languages. It has been around for a long time and is very well established for this task. Gettext helps you to open up your application for a much wider user base than you would normaly reach with only one language. Since it is used in many open source projects it has a lot of useful tools you can use to your own advantage. It would be possible to “roll your own” solution, but this would consume a large amount of time. Time you would lose for the development of your app. And this is not something you would want, right?

So in this tutorial I am going to show you how to effectively use Gettext for all your translation needs in your Ruby on Rails application.

What can Gettext do for you?

Here is a quick explanation of Gettext for those of you who haven’t worked with it, yet. Gettext is a set of tools that provide help when translating strings in your software. It gives you (straight from the gettext manual):

  • A set of conventions about how programs should be written to support message catalogs.
  • A directory and file naming organization for the message catalogs themselves.
  • A runtime library supporting the retrieval of translated messages.
  • A few stand-alone programs to massage in various ways the sets of translatable strings, or already translated strings.

The only thing you have to do to your program sources is wrap all translatable strings with a method call: gettext(text) or shorter _(text). Example:

Without gettext:

notice = 'Thank you for buying our product.'

With gettext:

notice = _('Thank you for buying our product.')

For more details check this out

GetText on Rails

September 6, 2006 at 8:20 am Leave a comment

Protected: AN INSTANIA OF FRUSTRA

This content is password protected. To view it please enter your password below:

September 2, 2006 at 12:59 pm Enter your password to view comments.


Contact

sur.max(at)gmail.com
September 2006
M T W T F S S
« Aug   Oct »
 123
45678910
11121314151617
18192021222324
252627282930  

Power Shots

Subscribe