@taigikeyboard/taigi-cli
v0.1.5
Published
Bidirectional converter between Taiwanese phonetic systems: TL (Tai-lo), POJ (Pe-oh-e-ji), and TPS (方音符號), with tone mark / tone number conversion
Downloads
782
Maintainers
Readme
taigi-cli
Bidirectional converter between Taiwanese phonetic systems: Tâi-lô (TL), Pe̍h-ōe-jī (POJ), and Taiwanese Phonetic Symbols (TPS), with tone mark / tone number conversion.
Demo

Features
- Convert between TL, POJ, and TPS
- Tone mark ↔ tone number conversion
- Handles mixed text with punctuation and hyphens
- Preserves letter casing
Install
npm install -g @taigikeyboard/taigi-cliOr run without installing:
npx -p @taigikeyboard/taigi-cli tai tl poj "peh8-oe7-ji7"CLI
tai <from> <to|mark|number|num> [--ascii] [text...]
tai -f <system> -t <system> [--tone mark|number|num] [--ascii] [text...]Systems: tl, poj, tps. The CLI also accepts common aliases like tailo, tai-lo, and zhuyin.
Input comes from arguments, or from stdin if none given.
tai tl poj "peh8-oe7-ji7" # pe̍h-ōe-jī
echo "tai5-gi2" | tai tl tps # ㄉㄞˊ ㆣㄧˋ
tai tl num "pe̍h-uē-jī" # peh8-ue7-ji7
tai poj mark "peh8-oe7-ji7" # pe̍h-ōe-jī
tai -f poj -t poj --tone number --ascii "o͘-á"Use mark, number, or num as the second argument to convert tone format inside the same romanization system.
num is an alias for number.
--tone, --mark, --number, and --num are also available when --from and --to are the same (TL or POJ).
--ascii / --poj-ascii rewrites POJ o͘/ⁿ as oo/nn.
Stdin and files
If no text argument is provided, tai reads UTF-8 text from stdin and writes the converted text to stdout.
echo "tai5-gi2" | tai tl tps
tai tl poj < input.txt > output.txt
cat input.txt | tai poj tlNewlines are preserved, so tai can process multi-line files.
API
import { convert, toToneNumber, toToneMark } from "@taigikeyboard/taigi-cli";
convert("tshiu-a", "tl", "poj"); // "chhiu-a"
convert("chhiu-a", "poj", "tl"); // "tshiu-a"
convert("tshiu7 a2", "tl", "zhuyin"); // TPS output
toToneNumber("Gâu-tsá"); // "Gau5-tsa2"
toToneMark("tshiu7-a2"); // "tshiú-á"
toToneMark("tshiu7-a2", "poj"); // "chhiú-á"Note: the programmatic API uses "zhuyin" as the system name for TPS.
Web
Live at taigikeyboard.tw.
Development
Node.js 22+, no dependencies, tests via built-in node:test.
npm test