diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-05-18 14:51:22 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-05-18 14:51:22 -0400 |
| commit | c412f5d69af032b6cc6e985c9591c3a106de704b (patch) | |
| tree | 948177336e1c8dc2a65125e71503f435c312817b /packages/frontend/src/components/SkNoteTranslation.vue | |
| parent | fix type errors in note translation source (diff) | |
| download | sharkey-c412f5d69af032b6cc6e985c9591c3a106de704b.tar.gz sharkey-c412f5d69af032b6cc6e985c9591c3a106de704b.tar.bz2 sharkey-c412f5d69af032b6cc6e985c9591c3a106de704b.zip | |
extract common translation UI into SkNoteTranslation.vue
Diffstat (limited to 'packages/frontend/src/components/SkNoteTranslation.vue')
| -rw-r--r-- | packages/frontend/src/components/SkNoteTranslation.vue | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/frontend/src/components/SkNoteTranslation.vue b/packages/frontend/src/components/SkNoteTranslation.vue new file mode 100644 index 0000000000..75fe11988c --- /dev/null +++ b/packages/frontend/src/components/SkNoteTranslation.vue @@ -0,0 +1,48 @@ +<!-- +SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors +SPDX-License-Identifier: AGPL-3.0-only +--> + +<template> +<div v-if="translating || translation != null" :class="$style.translation"> + <MkLoading v-if="translating" mini/> + <div v-else-if="translation && translation.text != null"> + <b v-if="translation.sourceLang">{{ i18n.tsx.translatedFrom({ x: translation.sourceLang }) }}: </b> + <Mfm :text="translation.text" :isBlock="true" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis" class="_selectable"/> + </div> + <div v-else>{{ i18n.ts.translationFailed }}</div> +</div> +</template> + +<script setup lang="ts"> +import * as Misskey from 'misskey-js'; +import { watch } from 'vue'; +import { i18n } from '@/i18n'; + +const props = withDefaults(defineProps<{ + note: Misskey.entities.Note; + translating?: boolean; + translation?: Misskey.entities.NotesTranslateResponse | false | null; +}>(), { + translating: false, + translation: null, +}); + +if (_DEV_) { + // Prop watch syntax: https://stackoverflow.com/a/59127059 + watch( + [() => props.translation, () => props.translating], + ([translation, translating]) => console.debug('Translation status changed: ', { translation, translating }), + { immediate: true }, + ); +} +</script> + +<style module lang="scss"> +.translation { + border: solid 0.5px var(--MI_THEME-divider); + border-radius: var(--MI-radius); + padding: 12px; + margin-top: 8px; +} +</style> |