This commit is contained in:
mattyatea 2023-10-29 19:26:49 +09:00
parent b3084f45b4
commit 699d4634b2

View file

@ -8,9 +8,9 @@ export function nyaize(text: string): string {
// ja-JP
.replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ')
// en-US
.replace(/(n)a/gi, (match, p1) => p1 === 'A' ? 'YA' : 'ya')
.replace(/(morn)ing/gi, (match, p1) => p1 === 'ING' ? 'YAN' : 'yan')
.replace(/(every)one/gi, (match, p1) => p1 === 'ONE' ? 'NYAN' : 'nyan')
.replace(/(na|NA)(?=[^a-z])/g, (match) => match === 'NA' ? 'NYA' : 'nya')
.replace(/(morn)(ing)(?=[^a-z])/gi, (match, p1, p2) => p2 === 'ING' ? `${p1}YAN` : `${p1.toLowerCase()}yan`)
.replace(/(every)(one)(?=[^a-z])/gi, (match, p1, p2) => p2 === 'ONE' ? `${p1}NYAN` : `${p1.toLowerCase()}nyan`)
// ko-KR
.replace(/[나-낳]/g, match => String.fromCharCode(
match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0),