Class: Gonzui::CatalogRepository
- Inherits:
-
Object
- Object
- Gonzui::CatalogRepository
- Includes:
- GetText
- Defined in:
- lib/gonzui/gettext.rb
Instance Method Summary collapse
- #choose(lang_name) ⇒ Object
- #each ⇒ Object
-
#initialize(directory) ⇒ CatalogRepository
constructor
A new instance of CatalogRepository.
Methods included from GetText
#gettext, #gettext_noop, #load_catalog, #set_catalog
Constructor Details
#initialize(directory) ⇒ CatalogRepository
Returns a new instance of CatalogRepository.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gonzui/gettext.rb', line 37 def initialize(directory) @catalogs = {} Dir.entries(directory).each {|entry| file_name = File.join(directory, entry) if m = /^catalog\.([\w.-]+)$/.match(File.basename(file_name)) lang = m[1] catalog = load_catalog(file_name) @catalogs[lang] = catalog end } @catalogs["en"] = Hash.new {|h, k| k } end |
Instance Method Details
#choose(lang_name) ⇒ Object
51 52 53 |
# File 'lib/gonzui/gettext.rb', line 51 def choose(lang_name) @catalogs[lang_name] end |
#each ⇒ Object
55 56 57 58 59 |
# File 'lib/gonzui/gettext.rb', line 55 def each @catalogs.each {|lang_name, catalog| yield(lang_name, catalog) } end |