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