Skip to content

Commit

Permalink
HANYU is not TONGYONG, it was a mistake, this adds the HANYU pinyin
Browse files Browse the repository at this point in the history
  • Loading branch information
muan committed Jun 6, 2016
1 parent 118ecb8 commit cc76a96
Show file tree
Hide file tree
Showing 4 changed files with 432 additions and 418 deletions.
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -40,8 +40,12 @@ function processString (str, system) {
throw new Error('Input contains non-Chinese characters')
}

str = removeDiacritics(str).toUpperCase()

// romanization system
str = romanizationSys[removeDiacritics(str).toUpperCase()][system]
if (system !== 'HANYU') {
str = romanizationSys[str][system]
}

// titleCase
str = str.charAt(0).toUpperCase() + str.slice(1, str.length).toLowerCase()
Expand Down
18 changes: 14 additions & 4 deletions readme.md
Expand Up @@ -18,7 +18,8 @@ romanize(name_in_zhTW, system)
`system` String
- `WG` (default) https://en.wikipedia.org/wiki/Wade%E2%80%93Giles
- `MPS-II` https://en.wikipedia.org/wiki/Mandarin_Phonetic_Symbols_II
- `HANYU` https://en.wikipedia.org/wiki/Tongyong_Pinyin
- `TONGYONG` https://en.wikipedia.org/wiki/Tongyong_Pinyin
- `HANYU` https://en.wikipedia.org/wiki/Pinyin

## Examples

Expand All @@ -29,8 +30,11 @@ console.log(romanize('張懸'))
console.log(romanize('張懸', 'MPS-II'))
> Shiuan Jang

console.log(romanize('張懸', 'HANYU'))
console.log(romanize('張懸', 'TONGYONG'))
> Syuan Jhang

console.log(romanize('張懸', 'HANYU'))
> Xuan Zhang
```

```javascript
Expand All @@ -40,8 +44,11 @@ console.log(romanize('秋木安'))
console.log(romanize('秋木安', 'MPS-II'))
> Mu-An Chiou

console.log(romanize('秋木安', 'HANYU'))
console.log(romanize('秋木安', 'TONGYONG'))
> Mu-An Ciou

console.log(romanize('秋木安', 'HANYU'))
> Mu-An Qiu
```

```javascript
Expand All @@ -51,8 +58,11 @@ console.log(romanize('范姜峻宏'))
console.log(romanize('范姜峻宏', 'MPS-II'))
> Jiun-Hung Fan-Jiang

console.log(romanize('范姜峻宏', 'HANYU'))
console.log(romanize('范姜峻宏', 'TONGYONG'))
> Jyun-Hong Fan-Jiang

console.log(romanize('范姜峻宏', 'HANYU'))
> Jun-Hong Fan-Jiang
```

## Data Sources
Expand Down

0 comments on commit cc76a96

Please sign in to comment.