feat: apply language annotation to note contents
Co-authored-by: Eana Hufwe <eana@1a23.com>
This commit is contained in:
parent
4c38d9665e
commit
175b5250f7
10 changed files with 40 additions and 11 deletions
|
@ -81,6 +81,7 @@
|
|||
:text="getNoteSummary(appearNote.reply)"
|
||||
:plain="true"
|
||||
:nowrap="true"
|
||||
:lang="appearNote.reply.lang"
|
||||
:custom-emojis="note.emojis"
|
||||
/>
|
||||
</div>
|
||||
|
@ -127,6 +128,7 @@
|
|||
:text="translation.text"
|
||||
:author="appearNote.user"
|
||||
:i="$i"
|
||||
:lang="targetLang"
|
||||
:custom-emojis="appearNote.emojis"
|
||||
/>
|
||||
</div>
|
||||
|
@ -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;
|
||||
})();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<div class="content">
|
||||
<Mfm
|
||||
:text="preprocess(text).trim()"
|
||||
:lang="lang"
|
||||
:author="$i"
|
||||
:i="$i"
|
||||
advanced-mfm
|
||||
|
@ -24,6 +25,7 @@ import preprocess from "@/scripts/preprocess";
|
|||
|
||||
defineProps<{
|
||||
text: string;
|
||||
lang?: string;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
:text="translation.text"
|
||||
:author="appearNote.user"
|
||||
:i="$i"
|
||||
:lang="targetLang"
|
||||
:custom-emojis="appearNote.emojis"
|
||||
/>
|
||||
</div>
|
||||
|
@ -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;
|
||||
})();
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -131,6 +132,7 @@
|
|||
:text="getNoteSummary(notification.note.renote)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.renote.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -144,6 +146,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -157,6 +160,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -170,6 +174,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -183,6 +188,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
@ -196,6 +202,7 @@
|
|||
:text="getNoteSummary(notification.note)"
|
||||
:plain="true"
|
||||
:nowrap="!full"
|
||||
:lang="notification.note.lang"
|
||||
:custom-emojis="notification.note.emojis"
|
||||
/>
|
||||
</MkA>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<Mfm
|
||||
:text="choice.text"
|
||||
:plain="true"
|
||||
:lang="note.lang"
|
||||
:custom-emojis="note.emojis"
|
||||
/>
|
||||
<span v-if="showResult" class="votes"
|
||||
|
|
|
@ -147,6 +147,7 @@
|
|||
v-model="cw"
|
||||
class="cw"
|
||||
:placeholder="i18n.ts.annotation"
|
||||
:lang="language ?? undefined"
|
||||
@keydown="onKeydown"
|
||||
/>
|
||||
<textarea
|
||||
|
@ -156,6 +157,7 @@
|
|||
:class="{ withCw: useCw }"
|
||||
:disabled="posting"
|
||||
:placeholder="placeholder"
|
||||
:lang="language ?? undefined"
|
||||
data-cy-post-form-text
|
||||
@keydown="onKeydown"
|
||||
@paste="onPaste"
|
||||
|
@ -167,6 +169,7 @@
|
|||
ref="hashtagsInputEl"
|
||||
v-model="hashtags"
|
||||
class="hashtags"
|
||||
:lang="language ?? undefined"
|
||||
:placeholder="i18n.ts.hashtags"
|
||||
list="hashtags"
|
||||
/>
|
||||
|
@ -178,8 +181,18 @@
|
|||
@changeSensitive="updateFileSensitive"
|
||||
@changeName="updateFileName"
|
||||
/>
|
||||
<XPollEditor v-if="poll" v-model="poll" @destroyed="poll = null" />
|
||||
<XNotePreview v-if="showPreview" class="preview" :text="text" />
|
||||
<XPollEditor
|
||||
v-if="poll"
|
||||
v-model="poll"
|
||||
:lang="language ?? undefined"
|
||||
@destroyed="poll = null"
|
||||
/>
|
||||
<XNotePreview
|
||||
v-if="showPreview"
|
||||
class="preview"
|
||||
:lang="language ?? undefined"
|
||||
:text="text"
|
||||
/>
|
||||
<footer>
|
||||
<button
|
||||
v-tooltip="i18n.ts.attachFile"
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
class="text"
|
||||
:text="note.cw"
|
||||
:author="note.user"
|
||||
:lang="note.lang"
|
||||
:i="$i"
|
||||
:custom-emojis="note.emojis"
|
||||
/>
|
||||
|
@ -103,6 +104,7 @@
|
|||
:text="note.text"
|
||||
:author="note.user"
|
||||
:i="$i"
|
||||
:lang="note.lang"
|
||||
:custom-emojis="note.emojis"
|
||||
/>
|
||||
<MkA
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
:author="author"
|
||||
:custom-emojis="customEmojis"
|
||||
:is-note="isNote"
|
||||
:lang="lang"
|
||||
class="mfm-object"
|
||||
:class="{
|
||||
nowrap,
|
||||
|
@ -28,6 +29,7 @@ const props = withDefaults(
|
|||
customEmojis?: any;
|
||||
isNote?: boolean;
|
||||
advancedMfm: boolean;
|
||||
lang?: string;
|
||||
}>(),
|
||||
{
|
||||
plain: false,
|
||||
|
|
|
@ -44,6 +44,10 @@ export default defineComponent({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
render() {
|
||||
|
@ -558,6 +562,6 @@ export default defineComponent({
|
|||
);
|
||||
|
||||
// Parse ast to DOM
|
||||
return h("span", genEl(ast));
|
||||
return h("span", {lang: this.lang}, genEl(ast));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -150,6 +150,7 @@ export type Note = {
|
|||
fileIds: DriveFile["id"][];
|
||||
visibility: "public" | "home" | "followers" | "specified";
|
||||
visibleUserIds?: User["id"][];
|
||||
lang?: string;
|
||||
localOnly?: boolean;
|
||||
channel?: Channel["id"];
|
||||
myReaction?: string;
|
||||
|
|
Loading…
Reference in a new issue