Module GetText::Rails
In: lib/gettext/rails.rb

GetText::Rails supports Ruby on Rails. You add only 2 lines in your controller, all of the controller/view/models are targeted the textdomain.

See <Ruby-GetText-Package HOWTO for Ruby on Rails (www.yotabanana.com/hiki/ruby-gettext-howto-rails.html>.

Methods

Included Modules

GetText

Constants

Rails = ::Rails #:nodoc:

External Aliases

bindtextdomain -> _bindtextdomain

Public Instance methods

Returns locales which supported by the application. This function returns an reversed array of the locale strings under RAILS_ROOT/locale/*. It is used for restriction such as caching files.

Bind a textdomain(#{path}/#{locale}/LC_MESSAGES/#{domainname}.mo) to your program. Notes the textdomain scope becomes all of the controllers/views/models in your app. This is different from normal GetText.bindtextomain.

Usually, you don‘t call this directly in your rails application. Call init_gettext in ActionController::Base instead.

On the other hand, you need to call this in helpers/plugins.

  • domainname: the textdomain name.
  • options: options as a Hash.
    • :locale - the locale value such as "ja-JP". When the value is nil, locale is searched the order by this value > "lang" value of QUERY_STRING > params["lang"] > "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value > Default locale(en).
    • :path - the path to the mo-files. Default is "RAIL_ROOT/locale".
    • :charset - the charset. Generally UTF-8 is recommanded. And the charset is set order by "the argument of bindtextdomain" > HTTP_ACCEPT_CHARSET > Default charset(UTF-8).

Returns a normalized locale which is in available_locales.

[Validate]