Module: GetText::Rails

Includes:
GetText
Included in:
ActionController::Base, ActionMailer::Base, ActionMailer::Base
Defined in:
lib/gettext/rails.rb

Overview

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>.

Constant Summary collapse

Rails =

:nodoc:

::Rails

Constants included from GetText

VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GetText

N_, #Nn_, _, #add_default_locale_path, #bindtextdomain_to, bound_target, bound_targets, cached=, cached?, cgi, cgi=, charset=, clear_cache, create_mofiles, current_textdomain_info, each_textdomain, gettext, locale, locale=, msgmerge, msgmerge_all, n_, ngettext, ns_, nsgettext, output_charset, output_charset=, rgettext, rmsgfmt, rmsgmerge, s_, set_cgi, set_charset, set_locale, set_locale_all, set_output_charset, setlocale, sgettext, textdomain, #textdomain_to, update_pofiles

Class Method Details

.bindtextdomain(domainname, options = {}, locale = nil, charset = nil, with_model = true) ⇒ Object

call-seq: bindtextdomain(domainname, options = {})

Bind a textdomain(#path/#GetText.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” 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).

Note: Don’t use locale, charset, with_model argument(not in options). They are remained for backward compatibility.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/gettext/rails.rb', line 60

def bindtextdomain(domainname, options = {}, locale = nil, charset = nil, with_model = true)
  opt = {}
  if options.kind_of? CGI
	# For backward compatibility
	opt.merge!(:cgi => options, :locale => locale, :charset => charset)
  else
	opt.merge!(options)
  end
  opt[:path] ||= File.join(RAILS_ROOT, "locale")
  _bindtextdomain(domainname, opt)
end

.included(mod) ⇒ Object

:nodoc:



29
30
31
# File 'lib/gettext/rails.rb', line 29

def self.included(mod)  #:nodoc:
  mod.extend self
end

Instance Method Details

#_bindtextdomainObject

:nodoc:



27
# File 'lib/gettext/rails.rb', line 27

alias :_bindtextdomain :bindtextdomain