| Class | GetText::TextDomainManager |
| In: |
lib/gettext/textdomainmanager.rb
|
| Parent: | Object |
Manage TextDomain (Internal use only) A class/module is able to have plural textdomains.
| target | [R] | |
| textdomains | [R] |
# File lib/gettext/textdomainmanager.rb, line 39
39: def self.each_all
40: @@textdomain_all.each do |k, textdomain|
41: yield textdomain
42: end
43: end
Initialize a TextDomainManager
# File lib/gettext/textdomainmanager.rb, line 52
52: def initialize(target, locale)
53: @target = target
54: @locale = locale
55: @textdomains = {}
56: end
Gets the current output_charset.
# File lib/gettext/textdomainmanager.rb, line 35
35: def self.output_charset
36: @@output_charset
37: end
Sets the current output_charset.
# File lib/gettext/textdomainmanager.rb, line 29
29: def self.output_charset=(charset)
30: @@output_charset = charset
31: end
# File lib/gettext/textdomainmanager.rb, line 45
45: def self.textdomain(domainname)
46: @@textdomain_all[domainname]
47: end
Add a textdomain
# File lib/gettext/textdomainmanager.rb, line 62
62: def add_textdomain(domainname, options = {})
63: path = options[:path]
64: if $DEBUG
65: $stderr.print "Bind the domain '#{domainname}' to '#{@target}'. "
66: $stderr.print "Current locale is #{@locale.inspect}\n"
67: end
68: textdomain = @@textdomain_all[domainname]
69: if textdomain
70: textdomain.set_locale(@locale)
71: else
72: textdomain = TextDomain.new(domainname, path, @locale)
73: @@textdomain_all[domainname] = textdomain
74: end
75: @textdomains[domainname] = textdomain
76: textdomain
77: end
Iterate textdomains.
# File lib/gettext/textdomainmanager.rb, line 80
80: def each
81: @textdomains.each do |k, textdomain|
82: yield textdomain
83: end
84: self
85: end
Sets locale such as "de", "fr", "it", "ko", "ja_JP.eucJP", "zh_CN.EUC" …
Notice that you shouldn‘t use this for your own Libraries.
# File lib/gettext/textdomainmanager.rb, line 93
93: def set_locale(locale, force = false)
94: if locale != @locale or force
95: each do |textdomain|
96: textdomain.set_locale(locale, force)
97: end
98: @locale = locale
99: end
100: self
101: end