Class: I18nPoTools::Formats::RailsYamlFormat
- Inherits:
-
BaseFormat
- Object
- BaseFormat
- I18nPoTools::Formats::RailsYamlFormat
- Defined in:
- lib/i18n_po_tools/formats/rails_yaml_format.rb
Overview
NOTE: Yaml preformatted mode (: | ) do not work TODO: plurals support
Instance Attribute Summary
Attributes inherited from BaseFormat
Instance Method Summary collapse
Methods inherited from BaseFormat
#banner_msg, #file_encoding, #read_file, #read_with_options, #write_file, #write_with_options
Instance Method Details
#read(input_filename) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/i18n_po_tools/formats/rails_yaml_format.rb', line 9 def read(input_filename) content = read_file(input_filename) rails_yaml = YAML.load(content) locales = rails_yaml.keys if locales.length > 1 raise "Only one language per file supported" end flat_hash = rails_yaml[locales.first].implode #TODO: plurals flat_hash end |
#write(output_filename, data) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/i18n_po_tools/formats/rails_yaml_format.rb', line 23 def write(output_filename, data) content = "# "++"\n" data_with_locale = {} data_with_locale[[:language]] = data.explode content += data_with_locale.to_yaml write_file(output_filename, content) end |