From 175b5250f7ed41323a12c0cfba8e50866c8ae746 Mon Sep 17 00:00:00 2001 From: Eana Hufwe Date: Sat, 2 Mar 2024 11:03:01 +0000 Subject: [PATCH] feat: apply language annotation to note contents Co-authored-by: Eana Hufwe --- packages/client/src/components/MkNote.vue | 7 +++---- .../client/src/components/MkNotePreview.vue | 2 ++ packages/client/src/components/MkNoteSub.vue | 6 ++---- .../client/src/components/MkNotification.vue | 7 +++++++ packages/client/src/components/MkPoll.vue | 1 + packages/client/src/components/MkPostForm.vue | 17 +++++++++++++++-- .../client/src/components/MkSubNoteContent.vue | 2 ++ .../global/MkMisskeyFlavoredMarkdown.vue | 2 ++ packages/client/src/components/mfm.ts | 6 +++++- packages/firefish-js/src/entities.ts | 1 + 10 files changed, 40 insertions(+), 11 deletions(-) diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index f29b19e3cc..672939f9d9 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -81,6 +81,7 @@ :text="getNoteSummary(appearNote.reply)" :plain="true" :nowrap="true" + :lang="appearNote.reply.lang" :custom-emojis="note.emojis" /> @@ -127,6 +128,7 @@ :text="translation.text" :author="appearNote.user" :i="$i" + :lang="targetLang" :custom-emojis="appearNote.emojis" /> @@ -370,15 +372,12 @@ const enableEmojiReactions = defaultStore.state.enableEmojiReactions; const expandOnNoteClick = defaultStore.state.expandOnNoteClick; const lang = localStorage.getItem("lang"); const translateLang = localStorage.getItem("translateLang"); +const targetLang = (translateLang || lang || navigator.language)?.slice(0, 2); const isForeignLanguage: boolean = defaultStore.state.detectPostLanguage && appearNote.value.text != null && (() => { - const targetLang = (translateLang || lang || navigator.language)?.slice( - 0, - 2, - ); const postLang = detectLanguage(appearNote.value.text); return postLang !== "" && postLang !== targetLang; })(); diff --git a/packages/client/src/components/MkNotePreview.vue b/packages/client/src/components/MkNotePreview.vue index 62bcc0f0c5..9782778e19 100644 --- a/packages/client/src/components/MkNotePreview.vue +++ b/packages/client/src/components/MkNotePreview.vue @@ -9,6 +9,7 @@
(); diff --git a/packages/client/src/components/MkNoteSub.vue b/packages/client/src/components/MkNoteSub.vue index 194a72d4b1..2e5b594a62 100644 --- a/packages/client/src/components/MkNoteSub.vue +++ b/packages/client/src/components/MkNoteSub.vue @@ -51,6 +51,7 @@ :text="translation.text" :author="appearNote.user" :i="$i" + :lang="targetLang" :custom-emojis="appearNote.emojis" />
@@ -287,15 +288,12 @@ const enableEmojiReactions = defaultStore.state.enableEmojiReactions; const expandOnNoteClick = defaultStore.state.expandOnNoteClick; const lang = localStorage.getItem("lang"); const translateLang = localStorage.getItem("translateLang"); +const targetLang = (translateLang || lang || navigator.language)?.slice(0, 2); const isForeignLanguage: boolean = defaultStore.state.detectPostLanguage && appearNote.value.text != null && (() => { - const targetLang = (translateLang || lang || navigator.language)?.slice( - 0, - 2, - ); const postLang = detectLanguage(appearNote.value.text); return postLang !== "" && postLang !== targetLang; })(); diff --git a/packages/client/src/components/MkNotification.vue b/packages/client/src/components/MkNotification.vue index 4c31793a36..7ea46b5a57 100644 --- a/packages/client/src/components/MkNotification.vue +++ b/packages/client/src/components/MkNotification.vue @@ -118,6 +118,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> @@ -131,6 +132,7 @@ :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.renote.emojis" /> @@ -144,6 +146,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> @@ -157,6 +160,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> @@ -170,6 +174,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> @@ -183,6 +188,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> @@ -196,6 +202,7 @@ :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" + :lang="notification.note.lang" :custom-emojis="notification.note.emojis" /> diff --git a/packages/client/src/components/MkPoll.vue b/packages/client/src/components/MkPoll.vue index fb5445c6c7..4a3b79f471 100644 --- a/packages/client/src/components/MkPoll.vue +++ b/packages/client/src/components/MkPoll.vue @@ -22,6 +22,7 @@