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>.
Rails | = | ::Rails #:nodoc: |
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).
- :with_model - false if you want to ignore ActiveRecord support.
- :with_helper - false if you want to ignore ApplicationHelper support.
Note: Don‘t use locale, charset, with_model argument(not in options). They are remained for backward compatibility.