简体   繁体   中英

How to fix I18n Ruby on Rails files?

I sent english files to my client to be translated into korean. The files I sent had the following structure:

en:
  manage:
    title: "Manage Account"
    post_new_resume: "Post New Resume"

I tried to view the files in Textmate, and with UTF8 encoding, the files I got back look something this:

ko:
  manage:
    title: "��d ��"
    post_new_resume: "�̷¼� ���"

Basically gibberish. I also looked at the official translation files of rails from the I18n repository on github in UTF8 encoding and they actually show korean.

ko:
  units:
    byte: "바이트"
    kb: "킬로바이트"
    mb: "메가바이트"

I'm guessing that the files got damaged when the client sent them over (perhaps he saved them with the wrong encoding). My question is, what can I do to fix them?

Thanks!

Ended up using the iconv to solve the problem. First, require it:

require 'iconv'

Then, write a method like this:

  def self.korean_to_utf(text)
    Iconv.iconv('UTF-8//IGNORE','euc-kr', text).join
  end

Then use that as needed :)

您可以在textmate中以UTF-8归档=>“使用编码重新打开”吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM