lib/i18n_screwdriver.rb in i18n_screwdriver-1.2.0 vs lib/i18n_screwdriver.rb in i18n_screwdriver-2.0.0

- old
+ new

@@ -6,11 +6,11 @@ def self.filename(locale) "config/locales/application.#{locale}.yml" end def self.for_key(string) - string.gsub(/\./, "").strip + Digest::MD5.hexdigest(string.strip) end def self.load_translations(locale) filename = self.filename(locale) raise "File #{filename} not found!" unless File.exists?(filename) @@ -19,18 +19,26 @@ def self.write_translations(locale, translations) File.open(filename(locale), "w") do |file| file.puts "# use rake task i18n:update to generate this file" file.puts - file.puts({locale => translations}.to_yaml) + file.puts({locale => in_utf8(translations)}.to_yaml) file.puts end end def self.grab_texts_to_be_translated(string) [].tap do |texts| texts.concat(string.scan(/_\("([^"]+)"\)/).map{ |v| v[0] }) texts.concat(string.scan(/_\('([^']+)'\)/).map{ |v| v[0] }) + end + end + + def self.in_utf8(hash) + {}.tap do |result| + hash.each do |k, v| + result[k.encode('UTF-8')] = (v || "").encode('UTF-8') + end end end end