0.1.2 • Published 8 years ago

pinyinizer v0.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

Pinyinizer

Adds proper (Mandarin) Chinese tone diacritics to a string.

The four tones of Chinese are commonly represented by the numbers 1-4. This module enables one to take a string with numerical tone representation and transforming it into a string with proper tone diacritics.

NumericTone DiacriticDescription
ma1level
ma2rising
ma3dipping
ma4falling
mamaneutral

Installation

NPM:

npm install --save pinyinizer

Bower:

bower install --save pinyinizer

API

pinyinize(s: string): string

Returns a pinyinized string where all tone indicator numbers have been replaced with tone diacritics on the vowels.

Usage

NodeJS

const pinyinizer = require('pinyinizer');

let pinyinized = pinyinizer.pinyinize('ni3hao3 shi4jie4!');

console.log(pinyinized) // nĭhăo shìjiè!

Browser

In the browser, pinyinizer is exposed as Pinyinizer:

var pinyinized = Pinyinizer.pinyinize('ni3hao3 shi4jie4!');

console.log(pinyinized) // nĭhăo shìjiè!