P
Patrick Gundlach
Dear Rubyists,
I use ruby gettext (very nice, though!) and have split up my code in
several files, that I include with require. But in the new files, the
translation effect is lost.
--------------------------------------------------
require 'gettext'
include GetText
require 'beh'
class A
def initialize
bindtextdomain("hello","locale","fr")
end
def pr
puts _("Hello World")
end
end
class B
def pr
puts _("Hello World")
end
end
a=A.new
a.pr
b=B.new
b.pr
--------------------------------------------------
beh.rb:
#empty
--------------------------------------------------
this is OK. Both Hello World get translated. But if I move the code
"class B .... end" to the other file, only the first Hello World gets
translated. I have to put the line with bindtextdomain somewhere in
the second file to get gettext working correctly. I think that this
has something to do with ruby discarding local stuff when using
require.
I need to set the lang part in the file, because I have a web
application that should be able to switch language based on cookies.
Question: how should I set this up correctly?
Patrick
I use ruby gettext (very nice, though!) and have split up my code in
several files, that I include with require. But in the new files, the
translation effect is lost.
--------------------------------------------------
require 'gettext'
include GetText
require 'beh'
class A
def initialize
bindtextdomain("hello","locale","fr")
end
def pr
puts _("Hello World")
end
end
class B
def pr
puts _("Hello World")
end
end
a=A.new
a.pr
b=B.new
b.pr
--------------------------------------------------
beh.rb:
#empty
--------------------------------------------------
this is OK. Both Hello World get translated. But if I move the code
"class B .... end" to the other file, only the first Hello World gets
translated. I have to put the line with bindtextdomain somewhere in
the second file to get gettext working correctly. I think that this
has something to do with ruby discarding local stuff when using
require.
I need to set the lang part in the file, because I have a web
application that should be able to switch language based on cookies.
Question: how should I set this up correctly?
Patrick