mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-25 20:18:18 +09:00
0e4a111f81
Resolve #7779
16 lines
620 B
TypeScript
16 lines
620 B
TypeScript
export function nyaize(text: string): string {
|
|
return text
|
|
// ja-JP
|
|
.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
|
|
// en-US
|
|
.replace(/(?<=n)a/gi, x => x === 'A' ? 'YA' : 'ya')
|
|
.replace(/(?<=morn)ing/gi, x => x === 'ING' ? 'YAN' : 'yan')
|
|
.replace(/(?<=every)one/gi, x => x === 'ONE' ? 'NYAN' : 'nyan')
|
|
// ko-KR
|
|
.replace(/[나-낳]/g, match => String.fromCharCode(
|
|
match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
|
|
))
|
|
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, '다냥')
|
|
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, '냥');
|
|
}
|