# GetText: Works with en\_GB and en\_US, but doesn't with de\_DE!

**URL:** <https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148>\
**Category:** Rails\
**Created:** [January 11, 2006, 2:04pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148 "2006-01-11T14:04:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [January 11, 2006, 2:04pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/1 "2006-01-11T14:04:18Z")

</div>

Hi all

I’m trying to get GetText to work. I have the following folder  
structure:

|-myapp.pot  
|-de\_DE/:  
| `-myapp.po |-en_GB/: |`-myapp.po  
|-en\_US/:  
``-myapp.po

I run rake updatepo, and then rake makemo.

Now I set en-gb as default language in Firefox and run my app \>\> works!  
Then I set en-us as default language in Firefox and run my app \>\> works,  
too!  
Last but not least I set de-de as default language in Firefox and run my  
app \>\> Failure!

NoMethodError in Member#register

You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.unpack

* * *

RAILS\_ROOT: script/…/config/…  
Application Trace | Framework Trace | Full Trace

## /usr/lib/ruby/gems/1.8/gems/gettext-1.1.0/lib/gettext/mo.rb:66:in `load_from_stream' /usr/lib/ruby/gems/1.8/gems/gettext-1.1.0/lib/gettext/mo.rb:229:in`load\_from\_file’ /usr/lib/ruby/gems/1.8/gems/gettext-1.1.0/lib/gettext/mo.rb:229:in `open' /usr/lib/ruby/gems/1.8/gems/gettext-1.1.0/lib/gettext/mo.rb:229:in`load\_from\_file’ /usr/lib/ruby/gems/1.8/gems/gettext-1.1.0/lib/gettext/mo.rb:38:in `open’ … …

What’s the problem?? I just don’t get it to work… Any help is very  
appreciated. 🙂

Btw. how can I set a default language, so if the default language of the  
browser is not supported it displays the page e.g. in german?

Thanks a lot.  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [January 11, 2006, 2:11pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/2 "2006-01-11T14:11:15Z")

</div>

OK I just found out, that when I set “Arabic/Qatar” (ar-qa) as default  
language then the app works well and displays the stuff that I have  
written originally in the rhtml files with the \_() function.  
So when a language is not supported, then it displays me this default  
stuff, right?

So far, so good - the de\_DE still does not work… :-/

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [January 11, 2006, 2:27pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/3 "2006-01-11T14:27:56Z")

</div>

Hi,

On Wed, 11 Jan 2006 14:11:15 +0100  
Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK I just found out, that when I set “Arabic/Qatar” (ar-qa) as default  
> language then the app works well and displays the stuff that I have  
> written originally in the rhtml files with the \_() function.  
> So when a language is not supported, then it displays me this default  
> stuff, right?

Right.

> So far, so good - the de\_DE still does not work… :-/

Send me your whole application, if you can.

I’ll investigate it.

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [January 11, 2006, 3:10pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/4 "2006-01-11T15:10:48Z")

</div>

Hi,

On Wed, 11 Jan 2006 14:40:58 +0100  
Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Send me your whole application, if you can.
> > 
> > I’ll investigate it.
> 
> Thanks. Where can I send it to?

To me. removed\_email\_address@domain.invalid.

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [February 9, 2006, 1:57pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/5 "2006-02-09T13:57:07Z")

</div>

> Now I set en-gb as default language in Firefox and run my app \>\> works!  
> Then I set en-us as default language in Firefox and run my app \>\> works,  
> too!  
> Last but not least I set de-de as default language in Firefox and run my  
> app \>\> Failure!

I had similar problem but I didn’t get any error message so your problem  
might be different. Anyway make sure that your server has de\_DE locales  
installed. Check this with “locale -a” command, if not then install  
them. There is no info about this at Ruby gettext page.

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [January 11, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/6 "2006-01-11T14:40:58Z")

</div>

> Send me your whole application, if you can.
> 
> I’ll investigate it.

Thanks. Where can I send it to?

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [February 9, 2006, 2:12pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/7 "2006-02-09T14:12:36Z")

</div>

Hi,

On Thu, 9 Feb 2006 13:57:07 +0100  
Grzegorz D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Now I set en-gb as default language in Firefox and run my app \>\> works!  
> > Then I set en-us as default language in Firefox and run my app \>\> works,  
> > too!  
> > Last but not least I set de-de as default language in Firefox and run my  
> > app \>\> Failure!
> 
> I had similar problem but I didn’t get any error message so your problem  
> might be different. Anyway make sure that your server has de\_DE locales  
> installed. Check this with “locale -a” command, if not then install  
> them. There is no info about this at Ruby gettext page.

Ruby-GetText-Package doesn’t depend on the system locale.  
If you have a translated po file in po/#{lang}/ correctly,  
it will be shown the language even if your server doesn’t support your  
locale.

Anyway, I investigated his program …  
And in his case, he didn’t translate po/de\_DE/hisapp.po,  
so English was shown 😉

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [February 9, 2006, 2:47pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/8 "2006-02-09T14:47:48Z")

</div>

> Ruby-GetText-Package doesn’t depend on the system locale.  
> If you have a translated po file in po/#{lang}/ correctly,  
> it will be shown the language even if your server doesn’t support your  
> locale.

OK I understand. I guess that there is something wrong with my gettext  
package configuration. Please look below, I execute the hello.rb  
example:

greg@gdcomp:~/tmp/samples$ ls locale/  
cs de el es fr it ja ko nl pt\_BR sv

greg@gdcomp:~/tmp/samples$ LC\_ALL=de\_DE.utf8 ruby hello.rb  
Hallo Welt  
greg@gdcomp:~/tmp/samples$ LC\_ALL=ko\_KR.utf8 ruby hello.rb  
Hello World  
greg@gdcomp:~/tmp/samples$ LC\_ALL=sv\_SE.utf8 ruby hello.rb  
Hello World  
greg@gdcomp:~/tmp/samples$ LC\_ALL=sv\_FI.utf8 ruby hello.rb  
Hello World  
greg@gdcomp:~/tmp/samples$ LC\_ALL=cs\_CZ.utf8 ruby hello.rb  
Ahoj SvÄ?te

greg@gdcomp:~/tmp/samples$ locale -a  
C  
cs\_CZ.utf8  
de\_DE.utf8  
en\_US.utf8  
es\_ES.utf8  
fr\_FR.utf8  
hu\_HU.utf8  
it\_IT.utf8  
ja\_JP.utf8  
pl\_PL.utf8  
POSIX  
pt\_PT.utf8  
ru\_RU.utf8  
zh\_CN.utf8

after adding ko\_KR.UTF-8 UTF-8 to /etc/locale.gen and executing  
locale-gen (Ubuntu 5.10 linux disto)  
greg@gdcomp:~/tmp/samples$ LC\_ALL=ko\_KR.utf8 ruby hello.rb  
ì??ë?? ì?¸ì?

Works. I guess that there is a different way of changing a lang to use  
by hello example.

Regards,  
GD

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [February 9, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/gettext-works-with-en-gb-and-en-us-but-doesnt-with-de-de/52148/9 "2006-02-09T15:42:41Z")

</div>

Hi,

On Thu, 9 Feb 2006 14:47:48 +0100  
Grzegorz D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Ruby-GetText-Package doesn’t depend on the system locale.  
> > If you have a translated po file in po/#{lang}/ correctly,  
> > it will be shown the language even if your server doesn’t support your  
> > locale.
> 
> OK I understand. I guess that there is something wrong with my gettext  
> package configuration. Please look below, I execute the hello.rb  
>   
> Works. I guess that there is a different way of changing a lang to use  
> by hello example.

Ah, I see.

Ruby-GetText-Package depends on system locale if you use it on the  
console.

But “gettext/rails” doesn’t depend on system locale.  
#Because the information is from the www browser(not server side).

Here is Rails ML, so I answered the behavior of it on Rails.

P.S.  
If you’re interested in it, check gettext/cgi.rb.  
And the url below may help you:  
[http://www.yotabanana.com/hiki/ruby-gettext-howto-cgi.html#How+to+get+the+locale+information+from+WWW+browser](http://www.yotabanana.com/hiki/ruby-gettext-howto-cgi.html#How+to+get+the+locale+information+from+WWW+browser)
