Class: Ixtlan::Gettext::Manager
- Inherits:
-
Object
- Object
- Ixtlan::Gettext::Manager
- Defined in:
- lib/ixtlan/gettext/manager.rb
Constant Summary collapse
- DEFAULT =
should match ::Ixtlan::UserManagement::Domain.DEFAULT.name
'DEFAULT'
Instance Method Summary collapse
- #flush_caches(text_domain = nil) ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #use(locale, name = DEFAULT) ⇒ Object
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
27 28 29 30 31 |
# File 'lib/ixtlan/gettext/manager.rb', line 27 def initialize @default_repo = build( DEFAULT ) FastGettext.default_text_domain = DEFAULT FastGettext.add_text_domain DEFAULT, :type => :ixtlan end |
Instance Method Details
#flush_caches(text_domain = nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ixtlan/gettext/manager.rb', line 42 def flush_caches(text_domain = nil) if text_domain (FastGettext.caches[text_domain] || {}).clear else FastGettext.caches.clear end end |
#use(locale, name = DEFAULT) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/ixtlan/gettext/manager.rb', line 33 def use( locale, name = DEFAULT ) unless FastGettext.translation_repositories.key?( name ) repos = [ build( "#{name}" ), @default_repo ] FastGettext.add_text_domain name, :type=>:chain, :chain=> repos end FastGettext.set_locale(locale) FastGettext.text_domain = name end |