text_latin_reading 0.1.2 copy "text_latin_reading: ^0.1.2" to clipboard
text_latin_reading: ^0.1.2 copied to clipboard

Shows how text sounds, written in Latin letters. Japanese readings come from the system dictionary on iOS and from a bundled morphological dictionary on Android; other scripts go through ICU.

text_latin_reading #

文字列の「読み」をラテン文字で返します。

await TextLatinReading.of('こんにちは', 'ja');   // konnichiha
await TextLatinReading.of('東京駅', 'ja');       // tōkyō eki
await TextLatinReading.of('안녕하세요', 'ko');   // annyeonghaseyo
await TextLatinReading.of('hello', 'en');       // null(出す意味がないので)

出せないときは null を返します。呼ぶ側は null のとき行ごと隠してください。

仕組み #

日本語だけ別扱いです。ICU の Any-Latin は漢字を中国語読みにしてしまい (東京 → dōngjīng)、日本語の読みとしては使えないためです。

  • iOS … CFStringTokenizerkCFStringTokenizerAttributeLatinTranscription。 Apple の日本語辞書を使うので、追加のダウンロードは要りません。
  • Android … kuromoji(形態素解析)と IPADIC を同梱し、各語の読み(カタカナ)を 取ってから ICU の Katakana-Latin にかけます。APK が 6MB ほど増えます。

日本語以外は、どちらの OS も ICU の Any-Latin です。 韓国語・中国語(ピンイン)・タイ語・ロシア語・ギリシャ語・アラビア語・ ヒンディー語などが対象です。

制限 #

  • Android の ICU 変換は API 24 以降です。それ未満では日本語以外が null になります。
  • 読みは目安です。人名や固有名詞は辞書にない読みになることがあります。
0
likes
130
points
225
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Shows how text sounds, written in Latin letters. Japanese readings come from the system dictionary on iOS and from a bundled morphological dictionary on Android; other scripts go through ICU.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on text_latin_reading

Packages that implement text_latin_reading