From 867d415fea8e5fd7d48c9d6c3ac2dd702d3da582 Mon Sep 17 00:00:00 2001 From: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:47:17 +0000 Subject: [PATCH] copy --- locales/de.yml | 3 +++ locales/en.yml | 3 +++ src/components/TextareaCopyable.vue | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/locales/de.yml b/locales/de.yml index 2d75385b..6d39812c 100644 --- a/locales/de.yml +++ b/locales/de.yml @@ -78,6 +78,9 @@ toolCard: new: Neu search: label: Suche +copyClipboard: + tooltip: In die Zwischenablage kopieren + success: Kopiert! tools: categories: favorite-tools: Deine Lieblingstools diff --git a/locales/en.yml b/locales/en.yml index 5baceff1..d8f0c61d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -72,6 +72,9 @@ toolCard: new: New search: label: Search +copyClipboard: + tooltip: Copy to clipboard + success: Copied! tools: categories: favorite-tools: Your favorite tools diff --git a/src/components/TextareaCopyable.vue b/src/components/TextareaCopyable.vue index 9585177d..9a70cafe 100644 --- a/src/components/TextareaCopyable.vue +++ b/src/components/TextareaCopyable.vue @@ -10,6 +10,8 @@ import iniHljs from 'highlight.js/lib/languages/ini'; import markdownHljs from 'highlight.js/lib/languages/markdown'; import { useCopy } from '@/composable/copy'; +const { t } = useI18n(); +// eslint-disable-next-line vue/define-macros-order const props = withDefaults( defineProps<{ value: string @@ -22,9 +24,10 @@ const props = withDefaults( followHeightOf: null, language: 'txt', copyPlacement: 'top-right', - copyMessage: 'Copy to clipboard', + copyMessage: t('copyClipboard.tooltip'), }, ); + hljs.registerLanguage('sql', sqlHljs); hljs.registerLanguage('json', jsonHljs); hljs.registerLanguage('html', xmlHljs); @@ -37,7 +40,7 @@ const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(p const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) }; const { copy, isJustCopied } = useCopy({ source: value, createToast: false }); -const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value); +const tooltipText = computed(() => isJustCopied.value ? t('copyClipboard.success') : copyMessage.value);