Skip to content

toRomaji custom mapping not always respected #167

@gmarty

Description

@gmarty

Issue Type

Description

I an trying to use WanaKana to transliterate hiragana to romaji using the Hepburn romanisation system.
I have configured a custom mapping. There are cases where the custom mapping is not respected.

Steps to reproduce

const customRomajiMapping = {
  うう: 'û',
  おう: 'ô',
  くう: 'kû',
  こう: 'kô',
  すう: 'sû',
  そう: 'sô',
  つう: 'tsû',
  とう: 'tô',
  ぬう: 'nû',
  のう: 'nô',
  ふう: 'fû',
  ほう: 'hô',
  むう: 'mû',
  もう: 'mô',
  ゆう: 'yû',
  よう: 'yô',
  ろう: 'rû',
  ろう: 'rô',
  ぐう: 'gû',
  ごう: 'gô',
  ずう: 'zû',
  ぞう: 'zô',
  づう: 'zû',
  どう: 'dô',
  ぶう: 'bû',
  ぼう: 'bô',
  ぷう: 'pû',
  ぽう: 'pô',
  きゅう: 'kyû',
  きょう: 'kyô',
  しゅう: 'shû',
  しょう: 'shô',
  ちゅう: 'chû',
  ちょう: 'chô',
  にゅう: 'nyû',
  にょう: 'nyô',
  ひゅう: 'hyû',
  ひょう: 'hyô',
  みゅう: 'myû',
  みょう: 'myô',
  りゅう: 'ryû',
  りょう: 'ryô',
  ぎゅう: 'gyû',
  ぎょう: 'gyô',
  じゅう: 'jû',
  じょう: 'jô',
  ぢゅう: 'jû',
  ぢょう: 'jô',
  びゅう: 'byû',
  びょう: 'byô',
  ぴゅう: 'pyû',
  ぴょう: 'pyô',
}
name = toRomaji('こういち', { customRomajiMapping }) // Returns 'Kôichi' (correct)
name = toRomaji('いっこう', { customRomajiMapping }) // Returns 'Ikkou'
name = toRomaji('ゆうじ', { customRomajiMapping }) // Returns 'Yûji' (correct)
name = toRomaji('けんゆう', { customRomajiMapping }) // Returns 'Ken'yuu'

It seems that 'っ' or an apostrophe before the pattern trips it and the transliteration fails.

Versions

  • Browser: Node 20
  • OS/Device: Mac
  • Keyboard/Input Method: UTF-8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions