lib/aigu/importer.rb in aigu-0.2 vs lib/aigu/importer.rb in aigu-0.2.1
- old
+ new
@@ -29,11 +29,11 @@
@object = localize_content_keys(@object)
end
def write_yaml_files
@blob.each_pair do |file_name, hash|
- file_path = File.join(@output_directory, "#{file_name}.#{@locale}yml")
+ file_path = File.join(@output_directory, "#{file_name}.yml")
puts "Generating #{file_path}"
FileUtils.mkdir_p(File.dirname(file_path))
File.open(file_path, 'w+') do |file|
file << hash.to_yaml(line_width: 100_000_000)
@@ -58,10 +58,10 @@
end
end
end
end
- def localized_content_keys(content)
+ def localize_content_keys(content)
content.reduce({}) do |memo, (key, value)|
localized_key = key.gsub(/^([^|]+)\|/, "\\1.#{@locale}|#{@locale}.")
memo.merge localized_key => value
end
end