# Rails Engine localization with Ruby-GetText

**URL:** <https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033>\
**Category:** Rails I18n\
**Created:** [September 18, 2006, 9:45am UTC](https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033 "2006-09-18T09:45:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Masao\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Masao\_M](https://www.ruby-forum.com/u/Masao_M)\
**Post date:** [September 18, 2006, 9:45am UTC](https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033/1 "2006-09-18T09:45:13Z")

</div>

Hi,

Recently, some people ask me for the l10n of  
Engines with gettext.

So I wrote a HOWTO for it.  
[http://www.yotabanana.com/hiki/?ruby-gettext-howto-engines](http://www.yotabanana.com/hiki/?ruby-gettext-howto-engines)

And I localized login\_engine for an example.  
It includes English and Japanese messages.

[http://www.yotabanana.com/hiki/?c=plugin;plugin=attach\_download;p=ruby-gettext-howto-engines;file\_name=login\_engine\_v1.0.2.gettext.tar.gz](http://www.yotabanana.com/hiki/?c=plugin;plugin=attach_download;p=ruby-gettext-howto-engines;file_name=login_engine_v1.0.2.gettext.tar.gz)

HTH,

---

<div class="post-metadata">

**Author:** ![Masao\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Masao\_M](https://www.ruby-forum.com/u/Masao_M)\
**Post date:** [January 12, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033/2 "2007-01-12T15:48:36Z")

</div>

Masao M. wrote:

> Hi,
> 
> Recently, some people ask me for the l10n of  
> Engines with gettext.
> 
> So I wrote a HOWTO for it.  
> [http://www.yotabanana.com/hiki/?ruby-gettext-howto-engines](http://www.yotabanana.com/hiki/?ruby-gettext-howto-engines)
> 
> And I localized login\_engine for an example.  
> It includes English and Japanese messages.
> 
> [http://www.yotabanana.com/hiki/?c=plugin;plugin=attach\_download;p=ruby-gettext-howto-engines;file\_name=login\_engine\_v1.0.2.gettext.tar.gz](http://www.yotabanana.com/hiki/?c=plugin;plugin=attach_download;p=ruby-gettext-howto-engines;file_name=login_engine_v1.0.2.gettext.tar.gz)
> 
> HTH,

hello masao-san,

i’m currently trying l10n with gettext and have 2 problems in my  
application.

it looks like “rake updatepo” cannot find messages inside strings like  
output \<\< “

#{\_(‘my localized message’)}
”

is this a bug? do i need a newer version (i’m currently using the  
gettext-1.8.0-mswin32 gem)? or is it just me doing s.th. wrong?

and the second problem is that despite what language i want to enforce  
via  
GetText.locale = “fr\_CH”  
(right before init\_gettext in the application controller)  
it always seems to fall back to the HTTP\_ACCEPT\_LANGUAGE from the  
browser ☹

any help would be greatly appreciated!

best regards  
ralf

---

<div class="post-metadata">

**Author:** ![Masao\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Masao\_M](https://www.ruby-forum.com/u/Masao_M)\
**Post date:** [January 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033/3 "2007-01-19T16:29:24Z")

</div>

Hi,

On Fri, 12 Jan 2007 15:48:36 +0100  
Ralf V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hello masao-san,
> 
> i’m currently trying l10n with gettext and have 2 problems in my  
> application.
> 
> it looks like “rake updatepo” cannot find messages inside strings like  
> output \<\< “
> 
> #{\_(‘my localized message’)}
> ”
> 
> is this a bug? do i need a newer version (i’m currently using the  
> gettext-1.8.0-mswin32 gem)? or is it just me doing s.th. wrong?

Hmm. OK.  
I’ll try it. But I don’t know I can fix it.

Try this as work arround.  
“

%s
” % \_(‘my localized message’)

> and the second problem is that despite what language i want to enforce  
> via  
> GetText.locale = “fr\_CH”  
> (right before init\_gettext in the application controller)  
> it always seems to fall back to the HTTP\_ACCEPT\_LANGUAGE from the  
> browser ☹

This may be a bug of 1.8.0.  
Could you try CVS version ?

---

<div class="post-metadata">

**Author:** ![Masao\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Masao\_M](https://www.ruby-forum.com/u/Masao_M)\
**Post date:** [January 24, 2007, 11:50am UTC](https://www.ruby-forum.com/t/rails-engine-localization-with-ruby-gettext/69033/4 "2007-01-24T11:50:46Z")

</div>

Masao M. wrote:

> > and the second problem is that despite what language i want to enforce  
> > via  
> > GetText.locale = “fr\_CH”  
> > (right before init\_gettext in the application controller)  
> > it always seems to fall back to the HTTP\_ACCEPT\_LANGUAGE from the  
> > browser ☹
> 
> This may be a bug of 1.8.0.  
> Could you try CVS version ?

hi again,

tried now with 1.9.0 and it works! woohoo 🙂

but something else…  
today i read about the “haml” plugin for view templates (see  
[http://haml.hamptoncatlin.com](http://haml.hamptoncatlin.com)).  
which is really cool but gettext doesnt seem to get along with it at all  
☹

rake updatepo  
Error: #\<RubyLex::SyntaxError: unknown type of %string\> in app/views/  
test/test.haml:1  
#content{:style=\>‘padding:20px’}  
rake aborted!

do you see any chances to support haml-templates in the near future?  
i would really love to start using them, but without gettext support  
it’d be a no-go.

best regards,  
ralf
