Skip to content

A simple Javascript plugin to convert pinyin with numbers to tone marks

License

Notifications You must be signed in to change notification settings

quizlet/pinyin-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pinyin Converter

A simple Javascript plugin to convert pinyin with numbers to tone marks.
PinyinConverter.convert('ni3hao3') // returns 'nǐhǎo'

This plugin powers the Pinyin conversion on Quizlet.com and was conceived during one of our hacknights

Getting Started

Just add the pinyin_converter.js script to your site. There are no external dependencies.

Usage

PinyinConverter only has 1 method: PinyinConverter.convert(text)

var pinyin = PinyinConverter.convert("san1ren2xing2bi4you3wo3shi1");
// returns "sānrénxíngbìyǒuwǒshī"

// ü can be typed by using v
var pinyin = PinyinConverter.convert("lv4");
// returns "lǜ"

// works with uppercase chars too
var pinyin = PinyinConverter.convert("WO3 HEN3 XI3HUAN QUIZLET!");
// returns "WǑ HĚN XǏHUAN QUIZLET!"

Enjoy!

About

A simple Javascript plugin to convert pinyin with numbers to tone marks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published