Skip to content

Instantly share code, notes, and snippets.

@morgoth
Created March 1, 2010 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morgoth/318305 to your computer and use it in GitHub Desktop.
Save morgoth/318305 to your computer and use it in GitHub Desktop.
# config/initializers/i18n_ascii_8bit.rb
module I18n
module Backend
class Simple
def load_yml(filename)
traverse(YAML::load(IO.read(filename))) { |o| o.force_encoding(Encoding::ASCII_8BIT) if o.respond_to?(:force_encoding) }
end
def traverse(object, &block)
if object.kind_of? Hash
object.each_value { |o| traverse(o, &block) }
elsif object.kind_of? Array
object.each { |o| traverse(o, &block) }
else
yield object
end
object
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment