What is Ruby-GetText-Package?

Ruby-GetText-Package is a Localization(L10n) Library and Tools which is modeled after GNU gettext package.

The library converts the messages to localized messages properly using client-side locale information(environment variable or CGI variable).

And the tools for developers support to create, use, and modify localized message files(message catalogs) easily.


  • Translate singular/plural messages with simple APIs(similar to GNU gettext)
  • Thread safety. Message resources are shared from all threads, but returns translated messages of the current thread's locale.
  • Tools to find message IDs
    • Extract message IDs to po-files using rgettext from
      • ruby scripts
      • glade-2 XML file(.glade)
      • ERB file(.rhtml, .erb)
      • Anything (with your own parsers)
      • The po-files are compatible to GNU gettext.
    • rmsgfmt creates a mo-file from a po-file. The mo-file is compatible to GNU gettext(msgfmt).
    • Using rgettext/rmsgfmt as Rake tasks
  • textdomain's scope is adapt to ruby class/module mechanism.
    • A class/module can have plural textdomains.
    • a message is looked up in its class/module and ancestors.
  • CGI support (gettext/cgi)
    • Locale is retrieved from client informations using Ruby-Locale. (HTTP_ACCEPT_LANGUAGE, HTTP_ACCEPT_CHARSET, QUERY_STRING(lang), Cookies(lang)).
  • String%() is extended to use named argument such as <tt>%{foo}" %{:foo => 1}</tt>. Notes that Ruby-1.9.x supports this format by itself.
  • The mo-file is compatible with GNU gettext(msgfmt).
  • Pure ruby library (Since 1.90.0)
  • JRuby support(Since 1.90.0)
  • Ruby on Rails support (gettext/rails)
  • CGI support (gettext/cgi)


Ruby 1.8.4 or later<URL:>

GNU gettext 0.10.35 or later

If you are developer of an application which uses Ruby-GetText-Package, it's better to prepare this to maintain your po/mo files because of some useful tools.

For MS Windows, I highly recommand to install Ruby-GNOME2 Win32 GUI Installer since it includes GNU gettext. Notice to install Development environment, not Runtime environment.

If you are a user of the application(not developer), you don't need this.

Racc-1.4.3 or later

If you need to compile src/rmsgfmt.ry by yourself. Usually you don't need this.



  • gem

    #from rubyforge
    (sudo/su on POSIX system)
    gem install gettext
  • download tar-ball

    # De-Compress archive and enter its top directory.
    (sudo/su on POSIX system)
    ruby setup.rb

You can also install files in your favorite directory by supplying setup.rb some options. Try <tt>ruby setup.rb --help</tt>.

Environment Variables for users


Set your locale. ja_JP.eucJP, ja_JP.UTF-8, etc. If it's not set, it's set C under a UNIX environment, and it's read from the system environment under MS Windows.

$export LC_ALL="ja_JP.eucJP"


Set output-charset. UTF-8, euc-jp, etc. Usually, you don't need to set this variable.

$export OUTPUT_CHARSET="euc-jp"


Set RUBYOPT=rubygems if you install Ruby-GetText-Package with the gem command.

$export RUBYOPT=rubygems


This program is licenced under the same licence as Ruby. (See the file 'COPYING'.)


  • 2011-06-11 Updated - Masao
  • 2008-01-29 Updated for 1.90.0 - Masao
  • 2006-02-08 Revised. - Masao
  • 2006-01-17 Revised "Requirement" - Masao
  • 2005-12-23 Updated for 1.1.0 - Masao
  • 2005-09-11 Revised. - Eli Gordon
Last modified:2011/06/11 23:55:33
References:[YotaLab Storage] [Ruby-GetText-Package HOWTO]