From 3302f5eea2ebabcb5043a333806b69217ef907c9 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 9 Oct 2026 17:54:24 +0400 Subject: [PATCH] refac --- .../workspace/common/VersionDiff.svelte | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/lib/components/workspace/common/VersionDiff.svelte b/src/lib/components/workspace/common/VersionDiff.svelte index 174aab127d..29820323f2 100644 --- a/src/lib/components/workspace/common/VersionDiff.svelte +++ b/src/lib/components/workspace/common/VersionDiff.svelte @@ -9,6 +9,8 @@ import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; import XMark from '$lib/components/icons/XMark.svelte'; + // Keep the default key visible to i18next-parser; callers can supply another key. + // $i18n.t('Current'); export let currentLabel = 'Current'; export let showFileHeaders = true; let mode: 'split' | 'unified' = 'split'; @@ -70,13 +72,18 @@ $: metadata = Object.entries(diff.metadata).flatMap(([key, value]) => changes(key === 'meta' ? [] : [key], value.before, value.after) ); - const labels: Record = { - name: 'Name', - description: 'Description', - tags: 'Tags', - i18n: 'Translations' + let labels: Record; + $: labels = { + name: $i18n.t('Name'), + description: $i18n.t('Description'), + tags: $i18n.t('Tags'), + i18n: $i18n.t('Translations') + }; + $: statuses = { + added: $i18n.t('Added'), + deleted: $i18n.t('Deleted'), + modified: $i18n.t('Modified') }; - const statuses = { added: 'Added', deleted: 'Deleted', modified: 'Modified' }; async function loadFile(path: string) { if (results[path]?.loading || results[path]?.diff !== undefined || results[path]?.binary) @@ -120,7 +127,7 @@ name={mode === 'split' ? 'split-horizontal' : 'list'} size={13} class="shrink-0" - />{$i18n.t(mode === 'split' ? 'Split' : 'Unified')}{mode === 'split' ? $i18n.t('Split') : $i18n.t('Unified')} @@ -143,7 +150,7 @@ size={13} class="shrink-0 text-gray-500" />{$i18n.t(option === 'split' ? 'Split' : 'Unified')}{option === 'split' ? $i18n.t('Split') : $i18n.t('Unified')}{#if mode === option}{/if}{/each} @@ -168,7 +175,7 @@ {#each metadata as change}
- {change.path.map((key) => $i18n.t(labels[key] || key)).join(' / ')} + {change.path.map((key) => labels[key] || $i18n.t(key)).join(' / ')}
{$i18n.t(statuses[file.status])}{statuses[file.status]} {/if} @@ -229,11 +236,9 @@ {:else}

- {$i18n.t( - results[file.path]?.line_endings_only - ? 'Only line endings changed' - : 'No text differences' - )} + {results[file.path]?.line_endings_only + ? $i18n.t('Only line endings changed') + : $i18n.t('No text differences')}

{/if}