¶ ↑
Ruby汉字转拼音Chinese Pinyin conversionChinese Pinyin conversion. 汉字转拼音 => Elvuel::Hz2py Chinese traditional and simplified conversion. 繁简转换 => Elvuel::TraditionalAndSimplified
¶ ↑
Installgem install hz2py
¶ ↑
In railsAs GEM rails3: gem ‘hz2py’ rails2: config.gem ‘hz2py’ As PLUGIN rails3: rails plugin install git://github.com/elvuel/hz2py.git rails2: ./script/plugin install git://github.com/elvuel/hz2py.git
¶ ↑
Usage & Example# in rails app add config/initializers/hz2py.rb class String def to_pinyin Hz2py.do(self) end end
Hz2py.do(“你好”) => “ni hao” TraditionalAndSimplified.conv_t2s(“鳳凰”) => “凤凰” TraditionalAndSimplified.conv_s2t(“无心插柳柳成阴”) => “無心插柳柳成陰” Hz2py.do(“你好”, :join_with => ‘-’) => “ni-hao” Hz2py.do(“愛你”, :join_with => ‘-’, :to_simplified => true) => “ai-ni”
¶ ↑
Testrspec spec/
¶ ↑
AuthorElvuel(elvuel@gmail.com) Copyright © 2010 elvuel(elvuel.com), released under the MIT license