rails I18n L10n - how to?

29 views
Skip to first unread message

campesr

unread,
Aug 8, 2008, 3:25:12 PM8/8/08
to rails-i18n
Hi,

so now we have this fundamental rails backend for i18n.

That's cool. Something new. I love Rails.

But what's the best approach at the moment, if I'd like to have my
application, including rails standard messages translated into
whatever language - in a gettext (Wordpress) way? I've used "ruby-
gettext" gem, but it's kind of not really worked out, in my opinion.

Cheers

Sven Fuchs

unread,
Aug 9, 2008, 5:24:28 AM8/9/08
to rails...@googlegroups.com
On 08.08.2008, at 21:25, campesr wrote:
> But what's the best approach at the moment, if I'd like to have my
> application, including rails standard messages translated into
> whatever language

Here are the two first writeups about this that I know of:

http://almosteffortless.com/2008/07/21/simple-localization-in-rails-22/
http://iain.nl/2008/08/finally-rails-goes-i18n/

If you find something else, please let me know. We're trying to
collect everything over here:

http://rails-i18n.org/wiki


> - in a gettext (Wordpress) way? I've used "ruby-
> gettext" gem, but it's kind of not really worked out, in my opinion.

Can you explain how ruby-gettext is not really worked out? I'm getting
asked a lot of questions about gettext recently and I can't really
answer them because I've personally not used gettext in years. So I'd
like to learn some more real-world opinions about it.


--
sven fuchs sven...@artweb-design.de
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)


campesr

unread,
Aug 9, 2008, 6:07:20 AM8/9/08
to rails-i18n


On 9 Aug., 11:24, Sven Fuchs <svenfu...@artweb-design.de> wrote:
> On 08.08.2008, at 21:25, campesr wrote:
>
> > But what's the best approach at the moment, if I'd like to have my
> > application, including rails standard messages translated into
> > whatever language
>
> Here are the two first writeups about this that I know of:
>
> http://almosteffortless.com/2008/07/21/simple-localization-in-rails-22/http://iain.nl/2008/08/finally-rails-goes-i18n/
>
> If you find something else, please let me know. We're trying to  
> collect everything over here:
>
> http://rails-i18n.org/wiki
>
> > - in a gettext (Wordpress) way? I've used "ruby-
> > gettext" gem, but it's kind of not really worked out, in my opinion.
>
> Can you explain how ruby-gettext is not really worked out? I'm getting  
> asked a lot of questions about gettext recently and I can't really  
> answer them because I've personally not used gettext in years. So I'd  
> like to learn some more real-world opinions about it.
>

Well, basically I like the way gettext handles localization. You have
the original (en-US for example) string as a key, and the localized
value as value.
The problem is, when you change just one comma, period, or anything,
the key => value mapping is screwed. The "Globalize" plugin for rails
tries to handle that, by assigning symbols to strings.
It works fine, but I don't really think it's good for the translation,
because the message may get out of date. For example, in the english
version you changed "Are you sure?" to "Are you sure, this is going to
delete the record?" -- the localizations will continue to work, but if
the second part of the sentence is missing, it's not the same thing
you will convey to the user.

I think the best solution would be the gettext way, with whole
sentences or words as keys, but with so called "string freezes". That
means that at a given date, none of the strings will be changed for
the current version, so the l10n-teams, can work the translations out.

But that's my opinion.

I've worked a lot with PHP and Wordpress, because I have my own blog
(as I think everybody does today). They handle localization totally
via gettext:

*Every* user-visible message (no matter if in a theme, or the core
wordpress code) is processed through the "__('message', 'domain');"
method. The only thing you need to do, is create the corresponding po/
mo-files (which is done automatically by poEdit for example; it scans
the source code, and looks for the "__();" method), and call the
"theme_text_domain('mydomain');" function. The mo-file is looked up in
a given directory, and your theme is being displayed in you preferred
language!

I've done this a couple of times, and it works great.

So basically I love the idea of rails-i18n's backend-independency.

I think rails-i18n should do two things: * provide a standard class,
with methods, which are overriden by different plugins to provide
backends. (one plugin is included, just to make it work, with a
standard rails distro)
* wrap
*all* rails standard user-visible messages in a "t('message',
'domain')" and "__('message', 'domain')".

Cheers

Diego Carrion

unread,
Aug 9, 2008, 3:02:11 PM8/9/08
to rails-i18n
Sven,

I wrote in my blog a few articles about Rails and i18n. They are in
portuguese but maybe they can own a space in the wiki:

Plugin in_place_edit agora com suporte a i18n
http://www.mouseoverstudio.com/blog/?p=114
Talks about the plugin fork with support to i18n and how to use it.

Formatando datas no Rails, agora com suporte a i18n
http://www.mouseoverstudio.com/blog/?p=112
Talks about how to format dates in Rails with I18n.localize

i18n on Rails => mudanças no helper date_select
http://www.mouseoverstudio.com/blog/?p=106
Talks about how to use the helper date_select with support to i18n.

Rocking mit i18n em Rails en 3 pasos
http://www.mouseoverstudio.com/blog/?p=105
Talks about how to use i18n with Rails, how to specify the locale and
the necessary resources.
> gr�nberger 65 + 49 (0) 30 - 47 98 69 96 (phone)

jos...@gmail.com

unread,
Aug 10, 2008, 12:51:58 PM8/10/08
to rails-i18n
Hi campesr -- thanks for your thoughts. We looked through a lot of
different localization possibilities when we were designing I18n for
Rails and the consensus was to stick with the Rubyish I18n.translate
and not the gettext _(). That being said, it's very easy to alias
I18n.translate to _() in your own plugin or app. If you look over the
edge Rails code, I think you'll find that we've done what you
proposed, except that the name of the translation method is translate
and not _().

On Aug 9, 1:07 pm, campesr <camp...@aol.com> wrote:
> On 9 Aug., 11:24, Sven Fuchs <svenfu...@artweb-design.de> wrote:
>
>
>
> > On 08.08.2008, at 21:25, campesr wrote:
>
> > > But what's the best approach at the moment, if I'd like to have my
> > > application, including rails standard messages translated into
> > > whatever language
>
> > Here are the two first writeups about this that I know of:
>
> >http://almosteffortless.com/2008/07/21/simple-localization-in-rails-2...

jos...@gmail.com

unread,
Aug 10, 2008, 12:54:36 PM8/10/08
to rails-i18n
Awesome, Diego! I can't read Portuguese but I think we find a place on
an i18n wiki for other languages than English :) It's great to see
this documentation come in in lots of different languages!

-- Josh

On Aug 9, 10:02 pm, Diego Carrion <dc.r...@gmail.com> wrote:
> Sven,
>
> I wrote in my blog a few articles about Rails and i18n. They are in
> portuguese but maybe they can own a space in the wiki:
>
> Plugin in_place_edit agora com suporte a i18nhttp://www.mouseoverstudio.com/blog/?p=114
> Talks about the plugin fork with support to i18n and how to use it.
>
> Formatando datas no Rails, agora com suporte a i18nhttp://www.mouseoverstudio.com/blog/?p=112
> Talks about how to format dates in Rails with I18n.localize
>
> i18n on Rails => mudanças no helper date_selecthttp://www.mouseoverstudio.com/blog/?p=106
> Talks about how to use the helper date_select with support to i18n.
>
> Rocking mit i18n em Rails en 3 pasoshttp://www.mouseoverstudio.com/blog/?p=105

Sven Fuchs

unread,
Aug 10, 2008, 2:17:55 PM8/10/08
to rails...@googlegroups.com
Hey Diego.

Welcome to the list!

Thanks for the links. I've listed them on the wiki: http://rails-i18n.org/wiki
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)

Diego Carrion

unread,
Aug 10, 2008, 5:02:06 PM8/10/08
to rails-i18n
Thanks Josh and Sven (:
> >> sven fuchs             svenfu...@artweb-design.de
> >> artweb design          http://www.artweb-design.de
> >> gr nberger 65                + 49 (0) 30 - 47 98 69 96 (phone)
> >> d-10245 berlin         + 49 (0) 171 - 35 20 38 4 (mobile)
>
> --
> sven fuchs              svenfu...@artweb-design.de

João Paulo Lins

unread,
Aug 10, 2008, 8:02:26 PM8/10/08
to rails...@googlegroups.com
Diego Good Job, I'm read your blog posts.

I'm Brazilian Rails too and wrote somethings about I18n in Portuguese.
My post is a complement for your post "Rocking mit i18n...".

http://www.minerama.net/2008/8/8/rails-i18n-catucando

Greetings from Brazil! ;-)

Sven Fuchs

unread,
Aug 11, 2008, 4:21:09 AM8/11/08
to rails...@googlegroups.com
Hi João

Welcome to the list :)

I've added your link to the wiki as well. Thanks!

You seem to have a pretty strong community over there in Brazil.
That's cool :)
--
sven fuchs sven...@artweb-design.de

Clemens Kofler

unread,
Aug 11, 2008, 4:54:56 AM8/11/08
to rails-i18n
My try: http://www.railway.at/articles/2008/08/10/localizing-rails
Already added it to the wiki. :-)
Reply all
Reply to author
Forward
0 new messages