summaryrefslogtreecommitdiff
path: root/src/misc/nyaize.ts
blob: 918e7d63fdc8fcc9adb64cc78eca92459c98ae0b (plain)
1
2
3
4
5
6
7
8
9
export function nyaize(text: string): string {
	return text
		// ja-JP
		.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
		// ko-KR
		.replace(/[나-낳]/g, match => String.fromCharCode(
			match.codePointAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
		));
}