wanglian / motion-pinyin

A RubyMotion wrapper for chinese_pinyin (https://github.com/flyerhzm/chinese_pinyin)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

motion-pinyin

Translate chinese hanzi to pinyin.

A RubyMotion wrapper for (https://github.com/flyerhzm/chinese_pinyin).

Install

Add this line to your application's Gemfile:

gem 'motion-pinyin'

And then execute:

$ bundle

Usage

Pinyin.t('**')  => "zhong guo"
Pinyin.t('你好world') => "ni hao world"
Pinyin.t('**', splitter: '-') => "zhong-guo"
Pinyin.t('**', splitter: '') => "zhongguo"
Pinyin.t('**', tone: true) => "zhong1 guo2"

Polyphone Issue

use Words.dat to override default behavior.

by default

Pinyin.t('广州') => "yan zhou"

add file Words.dat

广州|guang3 zhou1

set ENV['WORDS_FILE'] for Words.dat

ENV['WORDS_FILE'] = "Words.dat path"
Pinyin.t('广州') => "guang zhou"

About

A RubyMotion wrapper for chinese_pinyin (https://github.com/flyerhzm/chinese_pinyin)

License:MIT License


Languages

Language:Ruby 100.0%