Nonchalantly Performs Magic

    kana-romaji
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.10 • Public • Published

    kana-romaji, kana to alphabet converting library

    Hiragana is transformed into lower case output. Katakana is transformed into UPPER case output.

    toRomaji('ローマじ') // === 'RŌMAji';

    The sequences of same vowels and 'ou' output with prolonged vowel of the first. The sequence of 'ei' is not represented with long 'e'. ex)

    • 'ちちゅうかい', 'chichūkai'
    • 'ふりょう', 'furyō'
    • 'しょうがくせい', 'shōgakusei'

    Caveat

    The rule to not consider as prolonged vowel sound when the consecutive vowels are from separate Kanjis is not respected.

    ex) 'きいはんとうのばあい'

    • OK: 'kiihantōnobaai'
    • Our wrong output: 'kīhantōnobāi'

    Usage

    Typescript or modern es

    import { toRomaji } from 'kana-romaji';
    
    if (toRomaji('ローマじ') === 'RŌMAji') {
        // do your work
    }

    Old common JS

    var kanaRomaji = require("kana-romaji")
    
    console.log(kanaRomaji.toRomaji('おばあさん'))

    What about wanakana?

    WanaKana https://github.com/WaniKani/WanaKana offers various conversions between Kana and Romaji. Their functionality was somewhat limited in terms of rules of Romaji. Sequences of vowels 'おう' in 'こうこうせい' are transformed into 'ou' as in 'koukousei' instead of 'kōkōsei'. Despite all above, I appraise them! Thank you for being the inspiration!

    References

    University of Tokyo had the following document for recommended Romaji representation.

    I use this!

    I'm using this library inside word-decks https://github.com/mtomim/word-decks project, a simple learning-card application.

    Updates

    • Correction of issue #1, namely, "てぃ" => "tei" instead of "ti"
    • Use apostrophe (’) instead of hyphen (-) after 'n' and before a vowel (or 'y') when they are not to be pronounced together

    ex. ほんや => hon’ya, ほにゃ => honya

    • Prefer using 'n' for ん even before 'p', 'b' or 'm'

    Install

    npm i kana-romaji

    DownloadsWeekly Downloads

    11

    Version

    0.1.10

    License

    MIT

    Unpacked Size

    149 kB

    Total Files

    24

    Last publish

    Collaborators

    • mtomim