bring back Chinese cat mode
This commit is contained in:
parent
266078b549
commit
3ba12772d8
2 changed files with 32 additions and 28 deletions
|
@ -1,6 +1,5 @@
|
|||
export function nyaize(text: string): string {
|
||||
return (
|
||||
text
|
||||
export function nyaize(text: string, lang?: string): string {
|
||||
text = text
|
||||
// ja-JP
|
||||
.replaceAll("な", "にゃ")
|
||||
.replaceAll("ナ", "ニャ")
|
||||
|
@ -23,6 +22,10 @@ export function nyaize(text: string): string {
|
|||
// el-GR
|
||||
.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) : [];
|
||||
function nyaizeNode(node: mfm.MfmNode) {
|
||||
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) {
|
||||
for (const child of node.children) {
|
||||
|
|
Loading…
Reference in a new issue