# Gettext not worked in firefox,but done well under IE

**URL:** <https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881>\
**Category:** Rails\
**Created:** [May 8, 2006, 5:27am UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881 "2006-05-08T05:27:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [May 8, 2006, 5:27am UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881/1 "2006-05-08T05:27:38Z")

</div>

Anyone who has met such a kind of problem? I am adding i18n  
characteristics to my webapp using gettext,it works under IE,while not  
under firefox.  
here is my codes:  
po:  
po\zh\_CN\myapp.po

after rake makemo, i have got:  
locale\zh\_CN\LC\_MESSAGES\myapp.mo

require ‘gettext/rails’  
class ApplicationController \< ActionController::Base  
init\_gettext “myapp”  
end

Then I use the following to have a test in the application.rhtml  
\<%= local %\>  
\<% local=(“zh\_CN”) %\>  
\<%= local %\>  
\<%= \_(“Login”) %\>  
in IE,it can display as follows:  
en  
zh\_CN  
ç?»é??

but in firefox,it can not work:  
en  
zh\_CN  
Login

Am i wrong or ignore some procedures?

Thanks  
Charlie

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [May 8, 2006, 5:50am UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881/2 "2006-05-08T05:50:34Z")

</div>

I’ve gotten GetText 1.4 and Firefox 1.5.0.3 to work. Not sure how you  
set the lang (locale). I have mine be the first of  
request.env[‘HTTP\_ACCEPT\_LANGUAGE’].

DD

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [May 8, 2006, 7:22am UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881/3 "2006-05-08T07:22:20Z")

</div>

Doug D. wrote:

> I’ve gotten GetText 1.4 and Firefox 1.5.0.3 to work. Not sure how you  
> set the lang (locale). I have mine be the first of  
> request.env[‘HTTP\_ACCEPT\_LANGUAGE’].
> 
> DD

It seems that I can not use GetText.local= to set lang value,although I  
have found it in the API of GetText :  
[http://www.yotabanana.com/hiki/ruby-gettext-api.html?ruby-gettext-api](http://www.yotabanana.com/hiki/ruby-gettext-api.html?ruby-gettext-api)

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [May 8, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881/4 "2006-05-08T14:33:21Z")

</div>

2006/5/8, charlie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

maybe this helps:  
[http://manuals.rubyonrails.com/read/book/16](http://manuals.rubyonrails.com/read/book/16)

it says:

Ruby-GetText chooses the current language by following these rules in  
the given order:

1. the first value passed the ‘locale’ parameter of  
GetText.bindtextdomain method call
2. ‘lang’ value of QUERY\_STRING
3. ‘lang’ value of the Cookie
4. the value of HTTP\_ACCEPT\_LANGUAGE
5. or default ‘en’ (English).

ciao,  
robert

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [May 8, 2006, 3:22pm UTC](https://www.ruby-forum.com/t/gettext-not-worked-in-firefox-but-done-well-under-ie/59881/5 "2006-05-08T15:22:55Z")

</div>

Hi,

On Mon, 8 May 2006 05:27:38 +0200  
charlie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> require ‘gettext/rails’  
> en  
> zh\_CN  
> ç?»é??
> 
> but in firefox,it can not work:  
> en  
> zh\_CN  
> Login
> 
> Am i wrong or ignore some procedures?

Did your code work?

I think you need to use locale not local.  
and also local=(“zh\_CN”) set “zh\_CN” to “local” variable.

If you really want to work this sample, then

> require ‘gettext/rails’  
> class ApplicationController \< ActionController::Base  
> GetText.locale = “zh\_CN”  
> init\_gettext “myapp”  
> end

BTW,  
Try “zh” locale instead of “zh\_CN”.

locale\zh\_CN\LC\_MESSAGES\myapp.mo  
 → locale\zh\LC\_MESSAGES\myapp.mo

I suspect your locale of FireFox is “zh” not “zh\_CN”.  
(Check Edit → Preferences → Advanced → Edit Languages)
