feat: use i18n in components

This commit is contained in:
2026-08-25 08:32:43 +05:00
parent 74a18d91a7
commit 396036802c
11 changed files with 48 additions and 26 deletions
+10 -4
View File
@@ -1,29 +1,35 @@
<script lang="ts">
import { downloadBlob } from '$lib/core/io';
import { t } from '$lib/i18n/t';
import { getMergedDict } from '$lib/i18n/locale.svelte';
interface Props {
text: string;
filename: string;
toolId?: string;
}
let { text, filename }: Props = $props();
let { text, filename, toolId }: Props = $props();
const shown = $derived(
toolId ? (getMergedDict().tools[toolId]?.results?.[text] ?? text) : text
);
let copied = $state(false);
async function copy() {
await navigator.clipboard.writeText(text);
await navigator.clipboard.writeText(shown);
copied = true;
setTimeout(() => (copied = false), 1500);
}
function download() {
downloadBlob(new Blob([text], { type: 'text/plain' }), `${filename}.txt`);
downloadBlob(new Blob([shown], { type: 'text/plain' }), `${filename}.txt`);
}
</script>
<div class="panel text-result">
<textarea class="output" rows="10" readonly value={text} aria-label={t('textResult.outputAria')}></textarea>
<textarea class="output" rows="10" readonly value={shown} aria-label={t('textResult.outputAria')}></textarea>
<div class="actions">
<button type="button" class="secondary" onclick={copy}>
{copied ? t('textResult.copied') : t('textResult.copy')}