cspell icon indicating copy to clipboard operation
cspell copied to clipboard

💡: Chinese Pinyin (Romanization) Support

Open sghng opened this issue 9 months ago • 3 comments

Problem

In a mixed English/Chinese development environment, sometimes Chinese pinyin (a romanization method for mandarin Chinese) is used as var names. It'd be great if these var names, if correctly following pinyin rules, can be considered as correct words.

There are only finite combinations of consonants and vowels in pinyin. For example, bo, po, mo, fo, are all valid, ko or do are not. Any combinations of these valid syllables can be considered as "word".

Solution

I can think of two ways to do this:

  • A simple dictionary of all valid Chinese pinyin syllables. In some cases, to achieve the desired outcome, user will have to also enable the combination word option.
  • A "plugin" that extends the features of cspell, that "filters" a typo, if it doesn't fall into any dictionary but follows Chinese pinyin rule. I'm not sure if this is feasible.

Alternatives

No response

Additional Context

cspell team may not be ready to implement this yet. Are there any guides for community dictionaries and plugins? Is there an elegant way to distribute custom dictionaries through NPM?

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

sghng avatar Mar 28 '25 04:03 sghng

@sghng,

Is there a Pinyin dictionary?

Jason3S avatar Apr 18 '25 15:04 Jason3S

@sghng,

Is there a Pinyin dictionary?

I found this one: https://www.yellowbridge.com/chinese/pinyin-combo.php

Initials are consonants, finals are vowels.

It's quite regular so I think it's feasible to write a short script to generate all the valid conbinations.

sghng avatar Apr 18 '25 15:04 sghng

A better one from WikiPedia https://en.wikipedia.org/wiki/Pinyin_table

sghng avatar Apr 18 '25 15:04 sghng