lib/i15r.rb in i15r-0.5.3 vs lib/i15r.rb in i15r-0.5.4

- old
+ new

@@ -1,6 +1,7 @@ require 'i15r/pattern_matcher' +require 'i15r/locale_creator' class I15R class AppFolderNotFound < Exception; end class Config @@ -33,10 +34,11 @@ def initialize(reader, writer, printer, config={}) @reader = reader @writer = writer @printer = printer + @locale_creator = I15R::LocaleCreator.new(config[:create_locale_file]) @config = I15R::Config.new(config) end def config=(hash) @config = I15R::Config.new(hash) @@ -77,11 +79,14 @@ i18ned_text = sub_plain_strings(text, full_prefix(path), template_type.to_sym) @writer.write(path, i18ned_text) unless config.dry_run? end def sub_plain_strings(text, prefix, file_type) - pm = I15R::PatternMatcher.new(prefix, file_type, :add_default => config.add_default, + pm = I15R::PatternMatcher.new(prefix, + file_type, + @locale_creator, + :add_default => config.add_default, :override_i18n_method => config.override_i18n_method) transformed_text = pm.run(text) do |old_line, new_line| @printer.print_diff(old_line, new_line) end transformed_text + "\n" @@ -90,9 +95,10 @@ def internationalize!(path) @printer.println "Running in dry-run mode" if config.dry_run? path = "app" if path.nil? files = File.directory?(path) ? Dir.glob("#{path}/**/*.{erb,haml}") : [path] files.each { |file| internationalize_file(file) } + @locale_creator.save_file end def include_path? config.prefix_with_path || !config.prefix end