I’m glad that I found this list. Trying my first steps
with Rails, I found out that ruby-gettext is best suited
for my i18n needs. There’s one problem, though:
I’ve done a first rough custom translation of rails.po.
(The language I need is not shipped with ruby-gettext).
It works fine if I install the corresponding rails.mo
file into a system locale directory, i.e., into
/usr/lib/ruby/gems/1.8/gems/gettext-1.8.0/data/locale/eo.
However, I suppose that my webspace provider won’t put
a file into a system directory only for me. So I tried
to put the file into RAILS_ROOT/locale/eo. But as it turns
out, ruby-gettext is not interested in the file if I put
it there.
the directory in which ruby-gettext creates the .mo files should be
the right directory.
If I convert the po-file from
APP_ROOT/po/xxx.pot
APP_ROOT/po//xxx.po
ruby-gettext creates an mo-file in
APP_ROOT/locale//LC_MESSAGES/rails.mo
(where tag is like de_DE or en_GB).
And it works fine.
Here is my rakefile:
require ‘gettext/utils’
namespace:gettext do
desc “Update pot/po files to match new version.”
task :updatepo do
GetText.update_pofiles(“de”, Dir.glob(“app/**/*.{rb,rhtml}”),
“xxx 1.0”)
end
desc “Create mo-files for L10n”
task :makemo do
GetText.create_mofiles(true, “po”, “locale”, “%s/LC_MESSAGES”)
end
end
Moin Thomas, thanks for your reply. I’m afraid your advice did
not really help me. Maybe I should try and state the point of
my problem clearer.
Thomas B. wrote:
Don’t forget to insert
init_gettext “rails”
into your ApplicationController.
Basically, Gettext is working for me (translating e.g. table
names), which means that I have done this already. The thing
which does not work is only related to my rails.mo file,
generated from rails.po. This is po/rails.pot in the ruby-
gettext source directory. It contains default messages for
rails à la “%{num} errors prohibited this %{record} from being
saved”.
But it seems that these directories are not searched for rails.mo.
(Note that it works for eventoj.mo, the mo file for my application.)
Instead, rails.mo is in (for me)
/usr/lib/ruby/gems/1.8/gems/gettext-1.8.0/data/locale/*/LC_MESSAGES,
and found therein. My problem is that I do not want to put my custom
translation there, but do not understand how to tell Gettext that it
is somewhere else.
require ‘gettext’
include GetText
add_default_locale_path("/home/malte/Krakel/eventoj/locale/%{locale}/LC_MESSAGES/%{name}.mo")
require ‘gettext/rails’
and it works. It means to include GetText at the toplevel, because
ApplicationController does not exist yet when environment.rb is
executed, but it works.
@Thomas: You’re right, if I put rails.mo into locale/eo/ instead of
locale/eo/LC_MESSAGES/, then it is found. Actually, that is a nice
solution, too, and I think I will choose this one. Hm, if this is
a bug, then its source seems to be around line 200 of gettext/rails.rb.
Maybe the line
instead? Anyway, thank you both for solving my problem!
BTW, I think the best way to support your language is
to include your language in Ruby-GetText-Package.
If you help me, I can include your language to my official package. #Ask me directly if you are interested in it.
I’ll send you the po file as soon as I consider it finished. I’ll forget
this, so please remind me eventually And keep up the great work
you do on your Ruby libraries.
The GetText.add_default_locale_path methods should be called before
bindtextomain “rails”.
It means, you need to call it before requiring ‘gettext/rails’.
How about adding this code to the bottom of environment.rb(though I
don’t test it) ?:
BTW, I think the best way to support your language is
to include your language in Ruby-GetText-Package.
If you help me, I can include your language to my official package. #Ask me directly if you are interested in it.
instead? Anyway, thank you both for solving my problem!
No. the locale_path is the topdir of the locale path.
So, it becomes both of topdir/#{lang}/locale/foo.mo,
topdir/#{lang}/locale/LC_MESSAGES/foo.mo. #See gettext/textdomain.rb for more details.
BTW, I think the best way to support your language is
to include your language in Ruby-GetText-Package.
If you help me, I can include your language to my official package. #Ask me directly if you are interested in it.
I’ll send you the po file as soon as I consider it finished. I’ll forget
this, so please remind me eventually And keep up the great work
you do on your Ruby libraries.
I’ll send you the newest version of po files.
Thanks in advance.
Masao.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.