Module: Konjac::Translator
- Defined in:
- lib/konjac/translator.rb
Class Method Summary collapse
Class Method Details
.translate(files, from_lang, to_lang) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/konjac/translator.rb', line 5 def translate(files, from_lang, to_lang) pairs = Dictionary.load(from_lang, to_lang) files.each do |source| # Read in file and replace matches in content content = File.read(source) pairs.each do |pair| search, replace = pair puts "search = '%s', replace = '%s'" % [search, replace] content.gsub! search, replace end # Write changed content to file File.open(Utils.build_converted_file_name(source, from_lang, to_lang), "w") do |file| file.puts content end end end |