Chinese lang failed in SaltedHashLogin


#1

Hi,

I’m using SaltedHashLogin, it works well.

now, I want to switch language to be Chinese, so I edit a new yaml in
utf-8 with all
Chinese value inside.

Then I encouter “Rails application failed to start properly” problem
when start…

In the server.log, the error info is:
…/lib/localization.rb:55:in `iconv’: “\xe4\xb8\xad\xe6\x96\x87”
(Iconv::IllegalSequence)

And the code for this is:
def self.load_localized_strings
# Load language files
Dir[RAILS_ROOT + ‘/lang/*.yaml’].each do |filename|
filename =~ /(([a-z]+_?)+).yaml$/
hash = YAML::load(File.read(filename))
file_charset = hash[‘file_charset’] || ‘ascii’
lang = $1

  # convert string keys to symbols
  symbol_hash = Hash.new
  Iconv.open(CONFIG[:web_charset], file_charset) do |i|
    hash.each do |key, value|
      symbol_hash[key.to_sym] = i.iconv(value)
      if key =~ /^active_record_errors_(.*)/
        ActiveRecord::Errors.default_error_messages[$1.to_sym] =
          symbol_hash[key.to_sym]
      end
    end
  end

  LOCALIZED_STRINGS[lang] = symbol_hash
end

end

any one have any idea?
my lang file is saved in utf-8 format.

Thanks there,
ssyangy