chore: remove nyaification of 'nA'
This commit is contained in:
parent
85c034b1a2
commit
391328f128
2 changed files with 9 additions and 7 deletions
|
@ -1,11 +1,13 @@
|
||||||
export function nyaize(text: string, lang?: string): string {
|
export function nyaify(text: string, lang?: string): string {
|
||||||
text = 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"))
|
.replaceAll("na", "nya")
|
||||||
|
.replaceAll("Na", "Nya")
|
||||||
|
.replaceAll("NA", "NYA")
|
||||||
.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) =>
|
|
@ -12,7 +12,7 @@ import {
|
||||||
Channels,
|
Channels,
|
||||||
} from "../index.js";
|
} from "../index.js";
|
||||||
import type { Packed } from "@/misc/schema.js";
|
import type { Packed } from "@/misc/schema.js";
|
||||||
import { nyaize } from "@/misc/nyaize.js";
|
import { nyaify } from "@/misc/nyaify.js";
|
||||||
import { awaitAll } from "@/prelude/await-all.js";
|
import { awaitAll } from "@/prelude/await-all.js";
|
||||||
import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js";
|
import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js";
|
||||||
import type { NoteReaction } from "@/models/entities/note-reaction.js";
|
import type { NoteReaction } from "@/models/entities/note-reaction.js";
|
||||||
|
@ -262,19 +262,19 @@ export const NoteRepository = db.getRepository(Note).extend({
|
||||||
|
|
||||||
if (packed.user.isCat && packed.user.speakAsCat && packed.text) {
|
if (packed.user.isCat && packed.user.speakAsCat && packed.text) {
|
||||||
const tokens = packed.text ? mfm.parse(packed.text) : [];
|
const tokens = packed.text ? mfm.parse(packed.text) : [];
|
||||||
function nyaizeNode(node: mfm.MfmNode) {
|
function nyaifyNode(node: mfm.MfmNode) {
|
||||||
if (node.type === "quote") return;
|
if (node.type === "quote") return;
|
||||||
if (node.type === "text")
|
if (node.type === "text")
|
||||||
node.props.text = nyaize(node.props.text, packed.lang);
|
node.props.text = nyaify(node.props.text, packed.lang);
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
for (const child of node.children) {
|
for (const child of node.children) {
|
||||||
nyaizeNode(child);
|
nyaifyNode(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const node of tokens) nyaizeNode(node);
|
for (const node of tokens) nyaifyNode(node);
|
||||||
|
|
||||||
packed.text = mfm.toString(tokens);
|
packed.text = mfm.toString(tokens);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue