Project

hz2py

0.01
No commit activity in last 3 years
No release in over 3 years
汉字转拼音实现, Chinese pinyin conversion. Chinese Traditional and Simplified conversion
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.3.0
 Project Readme

Ruby汉字转拼音Chinese Pinyin conversion¶ ↑

Chinese Pinyin conversion. 汉字转拼音 => Elvuel::Hz2py Chinese traditional and simplified conversion. 繁简转换 => Elvuel::TraditionalAndSimplified

Install¶ ↑

gem install hz2py

In rails¶ ↑

As 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

String.class_eval do 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”

Test¶ ↑

rspec spec/

Author¶ ↑

Elvuel(elvuel@gmail.com) Copyright © 2010 elvuel(elvuel.com), released under the MIT license