Gettext not worked in firefox,but done well under IE


#1

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


#2

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


#3

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


#4

2006/5/8, charlie removed_email_address@domain.invalid:

maybe this helps:
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


#5

Hi,

On Mon, 8 May 2006 05:27:38 +0200
charlie 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)