Class: ReadyForI18N::LocaleDictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/locale_dictionary.rb

Instance Method Summary collapse

Constructor Details

#initialize(locale = nil) ⇒ LocaleDictionary

Returns a new instance of LocaleDictionary.



3
4
5
6
# File 'lib/locale_dictionary.rb', line 3

def initialize(locale = nil)
  @locale = locale || 'en'
  @hash = {}
end

Instance Method Details

#push(key, value, path = nil) ⇒ Object



7
8
9
10
11
# File 'lib/locale_dictionary.rb', line 7

def push(key,value,path = nil)
  h = @hash
  path.each{|p| h[p] ||= {}; h = h[p] } if path
  h[key] = value
end

#write_to(out) ⇒ Object



12
13
14
15
16
# File 'lib/locale_dictionary.rb', line 12

def write_to(out)
  # out.puts "#{@locale}:"
  $KCODE = 'UTF8'
  out.puts({"#{@locale}" => @hash}.ya2yaml)
end