bring back Chinese cat mode
This commit is contained in:
parent
266078b549
commit
3ba12772d8
@ -1,28 +1,31 @@
|
|||||||
export function nyaize(text: string): string {
|
export function nyaize(text: string, lang?: string): string {
|
||||||
return (
|
text = text
|
||||||
text
|
// ja-JP
|
||||||
// ja-JP
|
.replaceAll("な", "にゃ")
|
||||||
.replaceAll("な", "にゃ")
|
.replaceAll("ナ", "ニャ")
|
||||||
.replaceAll("ナ", "ニャ")
|
.replaceAll("ナ", "ニャ")
|
||||||
.replaceAll("ナ", "ニャ")
|
// en-US
|
||||||
// en-US
|
.replace(/(?<=n)a/gi, (x) => (x === "A" ? "YA" : "ya"))
|
||||||
.replace(/(?<=n)a/gi, (x) => (x === "A" ? "YA" : "ya"))
|
.replace(/(?<=morn)ing/gi, (x) => (x === "ING" ? "YAN" : "yan"))
|
||||||
.replace(/(?<=morn)ing/gi, (x) => (x === "ING" ? "YAN" : "yan"))
|
.replace(/(?<=every)one/gi, (x) => (x === "ONE" ? "NYAN" : "nyan"))
|
||||||
.replace(/(?<=every)one/gi, (x) => (x === "ONE" ? "NYAN" : "nyan"))
|
.replace(/non(?=[bcdfghjklmnpqrstvwxyz])/gi, (x) =>
|
||||||
.replace(/non(?=[bcdfghjklmnpqrstvwxyz])/gi, (x) =>
|
x === "NON" ? "NYAN" : "nyan",
|
||||||
x === "NON" ? "NYAN" : "nyan",
|
)
|
||||||
)
|
// ko-KR
|
||||||
// ko-KR
|
.replace(/[나-낳]/g, (match) =>
|
||||||
.replace(/[나-낳]/g, (match) =>
|
String.fromCharCode(
|
||||||
String.fromCharCode(
|
match.charCodeAt(0)! + "냐".charCodeAt(0) - "나".charCodeAt(0),
|
||||||
match.charCodeAt(0)! + "냐".charCodeAt(0) - "나".charCodeAt(0),
|
),
|
||||||
),
|
)
|
||||||
)
|
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, "다냥")
|
||||||
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, "다냥")
|
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, "냥")
|
||||||
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, "냥")
|
// el-GR
|
||||||
// el-GR
|
.replaceAll("να", "νια")
|
||||||
.replaceAll("να", "νια")
|
.replaceAll("ΝΑ", "ΝΙΑ")
|
||||||
.replaceAll("ΝΑ", "ΝΙΑ")
|
.replaceAll("Να", "Νια");
|
||||||
.replaceAll("Να", "Νια")
|
|
||||||
);
|
// zh-CN, zh-TW
|
||||||
|
if (lang === "zh") text = text.replace(/(妙|庙|描|渺|瞄|秒|苗|藐|廟)/g, "喵");
|
||||||
|
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,8 @@ export const NoteRepository = db.getRepository(Note).extend({
|
|||||||
const tokens = packed.text ? mfm.parse(packed.text) : [];
|
const tokens = packed.text ? mfm.parse(packed.text) : [];
|
||||||
function nyaizeNode(node: mfm.MfmNode) {
|
function nyaizeNode(node: mfm.MfmNode) {
|
||||||
if (node.type === "quote") return;
|
if (node.type === "quote") return;
|
||||||
if (node.type === "text") node.props.text = nyaize(node.props.text);
|
if (node.type === "text")
|
||||||
|
node.props.text = nyaize(node.props.text, packed.lang);
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
for (const child of node.children) {
|
for (const child of node.children) {
|
||||||
|
Loading…
Reference in New Issue
Block a user