# File lib/i18n/backend/gettext.rb, line 30
30: def load_po(filename)
31: locale = ::File.basename(filename, '.po').to_sym
32: data = normalize(locale, parse(filename))
33: { locale => data }
34: end
# File lib/i18n/backend/gettext.rb, line 40
40: def normalize(locale, data)
41: data.inject({}) do |result, (key, value)|
42: unless key.nil? || key.empty?
43: key, value = normalize_pluralization(locale, key, value) if key.index("\0000")
44:
45: parts = key.split('|').reverse
46: normalized = parts.inject({}) do |_normalized, part|
47: { part => _normalized.empty? ? value : _normalized }
48: end
49:
50: result.deep_merge!(normalized)
51: end
52: result
53: end
54: end
# File lib/i18n/backend/gettext.rb, line 56
56: def normalize_pluralization(locale, key, value)
57: # FIXME po_parser includes \000 chars that can not be turned into Symbols
58: key = key.gsub("\0000", I18n::Gettext::PLURAL_SEPARATOR).split(I18n::Gettext::PLURAL_SEPARATOR).first
59:
60: keys = I18n::Gettext.plural_keys(locale)
61: values = value.split("\0000")
62: raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect}" if values.size != keys.size
63:
64: result = {}
65: values.each_with_index { |_value, ix| result[keys[ix]] = _value }
66: [key, result]
67: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.