Build Status Coverage Status

Zh

Localization support for Mandarin.

Description

台灣、港澳、新加坡、中國,是目前世界上使用中文比重較高的國家,或是說是母語,但雖然同為中文,但在使用上除了繁簡的差異外,還有地方詞彙的不同,在中文的翻譯轉換之間,不只是繁簡的轉換,有些甚至是整個詞彙的轉換

以下舉幾個例子:

同為繁體的,以 tw, hk 為例

tw hk
數位單眼相機 數碼單鏡反光機

同為簡體,以 sg, cn 為例

sg cn
纽西兰 新西兰

繁簡轉換,以 tw, cn 為例

tw cn
複製人 克隆人

資料來源:可參考此專案的說明

這個 Gem 則是透過以上的轉換表,來幫助轉換各地方中文的歧異

Special thanks

這個 Gem 的概念源自於 siuying/zhconv,不過作者 siuying 最後的一筆 commit 已是兩年多前,部分資料已經有所變動,本來是想要 fork 來再做一些修正,但最後我想做的事情有些不同,決定獨立出來製作成一個 gem ,不送 pull request 給原作者,但還是感謝原作者的貢獻。

Installation

Add this line to your application's Gemfile:

gem 'zh'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zh

Usage

require 'zh'
puts Zh.to_tw("面包")
#=> "麵包"

Contributing

  1. Fork it ( https://github.com/zxlai/zh/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request