21 lines
787 B
TypeScript
21 lines
787 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
export function nyaize(text: string): string {
|
|
return text
|
|
// ja-JP
|
|
.replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ')
|
|
// en-US
|
|
.replace(/na/gi, (match) => match === 'NA' ? 'NYA' : 'nya')
|
|
.replace(/morning/gi, (match) => match === 'MORNING' ? 'MORNYAN' : 'mornyan')
|
|
.replace(/everyone/gi, (match) => match === 'EVERYONE' ? 'EVERYNYAN' : 'everynyan')
|
|
// ko-KR
|
|
.replace(/[나-낳]/g, match => String.fromCharCode(
|
|
match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0),
|
|
))
|
|
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, '다냥')
|
|
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, '냥');
|
|
}
|