On Wed, Feb 13, 2002 at 01:38:41AM +0900, Sergey A Yanovitsky wrote: > AB> This is unrelated to what Rdoc wants to support. Gettext is for > AB> multilingualized software, which wants to talk with user on different > AB> languages. Here we want to support comments in different languages, not a > AB> possiblity to specify commentary twice or more times in different language > AB> (for which gettext is usefull) in order to be able to produce different > AB> documentations for the same source. > On wiki Dave wrote that templates will contain static strings for > standard languages. That means if you use --lang=ru, ALL pages must be > in russian, not just your comments in them. So RDoc WILL talk in > different languages :). There are two different problem domains here. First is internationalization of RDoc, that's what you have described above. This is indeed usually done using gettext. However, it does nothing to localize report of RDoc-generated documentation because here you have to deal with processed sources themselves. This is an ability to write comments using some langauge and pass them correctly processed to the final report. This is different from gettext concept, completely different. In gettext, each translation is stored in different file and sources have only entry points (usually in English) which then resolved at run-time using appropriate hash file with translation. > However i don't suggest to use gettext with RDoc, just to look how it > makes proper LANG determination and do something similar in ruby. You don't need to look at gettext to make it proper. :) Use langauge,charset = /^([^.]+)\.?(.*)/m.match( ENV["LANG"].nil? ? "POSIX" : ENV["LANG"])[1,2] For example, on my system locale is be_BY.CP1251: irb(main):006:0> /^([^.]+)\.?(.*)/m.match(ENV["LANG"].nil? ? "POSIX" : ENV["LANG"])[1,2] ["be_BY", "CP1251"] And for locale without charset directly specified at LANG you have to use nl_langinfo(CODESET) call (defined in X/PG standard) and unfortunately unaccessible from Ruby for the moment. This is simple C call, something that can be wrapped like this: #include <locale.h> #include <langinfo.h> #include "ruby.h" void rb_get_codeset() { const char* locale = setlocale(LC_ALL,""); VALUE codeset = rb_str_new2(nl_langinfo(CODESET)); setlocale(LC_ALL, locale); return codeset; } As you can see, this involves C. -- / Alexander Bokovoy Software architect and analyst // SaM-Solutions Ltd. --- Q: What is purple and commutes? A: An Abelian grape.