mirror of
https://github.com/paricafe/misskey.git
synced 2025-03-15 01:29:17 -05:00
isUnexpectedNote
This commit is contained in:
parent
8120e320ab
commit
405b47140f
1 changed files with 12 additions and 6 deletions
|
@ -85,7 +85,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
:enableEmojiMenu="true"
|
||||
:enableEmojiMenuReaction="true"
|
||||
/>
|
||||
<div v-if="defaultStore.state.autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isForeignLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);">
|
||||
<div v-if="defaultStore.state.autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isUnexpectedLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);">
|
||||
<button v-if="!(translating || translation)" ref="translateButton" class="_button" @click.stop="translate()"><i class="ti ti-language-hiragana"></i>{{ i18n.ts.translate }}</button>
|
||||
<button v-else class="_button" @click.stop="translation= null">{{ i18n.ts.close }}</button>
|
||||
</div>
|
||||
|
@ -599,11 +599,17 @@ async function clip(): Promise<void> {
|
|||
os.popupMenu(await getNoteClipMenu({ note: note.value, isDeleted, currentClip: currentClip?.value }), clipButton.value).then(focus);
|
||||
}
|
||||
|
||||
const isForeignLanguage: boolean = appearNote.value.text != null && (() => {
|
||||
const targetLang = (miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2);
|
||||
const postLang = detectLanguage(appearNote.value.text);
|
||||
return postLang !== '' && postLang !== targetLang;
|
||||
})();
|
||||
function isUnexpectedNote(note: Misskey.entities.Note): boolean {
|
||||
if (!note.text) return false;
|
||||
const currentLang = (miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2);
|
||||
const expectedLangs = new Set([
|
||||
currentLang,
|
||||
navigator.language
|
||||
]);
|
||||
const postLang = detectLanguage(note.text);
|
||||
return postLang !== '' && !expectedLangs.has(postLang);
|
||||
}
|
||||
const isUnexpectedLanguage = computed(() => isUnexpectedNote(appearNote.value));
|
||||
|
||||
async function translate(): Promise<void> {
|
||||
if (translation.value != null) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue