From de7ca987a50249f2ecda4bf8f14b86de4003adaa Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 2 Jul 2026 15:45:01 -0500 Subject: [PATCH] refac --- .../components/Admin/AgentProfileModal.svelte | 8 +- .../src/lib/components/Admin/Agents.svelte | 4 +- .../Admin/CreateConnectionModal.svelte | 14 +- .../Admin/EditConnectionModal.svelte | 14 +- .../src/lib/components/Admin/Models.svelte | 10 +- cptr/frontend/src/lib/components/Bar.svelte | 8 +- .../src/lib/components/ChangelogModal.svelte | 2 +- .../src/lib/components/FileEditor.svelte | 7 +- .../frontend/src/lib/components/GitBar.svelte | 88 +++--- .../src/lib/components/GitView.svelte | 26 +- .../src/lib/components/PortPreview.svelte | 14 +- .../src/lib/components/SaveDialog.svelte | 2 +- .../src/lib/components/SetupWizard.svelte | 4 +- .../src/lib/components/ShortcutBar.svelte | 4 +- .../src/lib/components/UpdateToast.svelte | 2 +- .../automations/ScheduleDropdown.svelte | 52 ++-- .../src/lib/components/chat/ChatInput.svelte | 4 +- .../chat/FileSuggestionPopup.svelte | 7 +- .../lib/components/chat/OutputEditView.svelte | 4 +- .../src/lib/components/chat/SendButton.svelte | 6 +- .../chat/SkillSuggestionPopup.svelte | 8 +- .../lib/components/chat/StatusModal.svelte | 24 +- .../lib/components/common/Pagination.svelte | 2 +- .../src/lib/components/common/Spinner.svelte | 4 +- .../lib/components/markdown/CodeBlock.svelte | 7 +- .../components/markdown/EditorToolbar.svelte | 37 +-- .../components/markdown/InlineRenderer.svelte | 3 +- .../components/markdown/MermaidBlock.svelte | 6 +- .../components/preview/ImagePreview.svelte | 7 +- .../lib/components/preview/PDFViewer.svelte | 9 +- .../lib/components/preview/SqliteView.svelte | 2 +- .../lib/components/preview/SvgPreview.svelte | 7 +- cptr/frontend/src/lib/i18n/locales/de.json | 270 +++++++++++++----- cptr/frontend/src/lib/i18n/locales/en.json | 118 +++++++- cptr/frontend/src/lib/i18n/locales/es.json | 254 +++++++++++----- cptr/frontend/src/lib/i18n/locales/fr.json | 266 ++++++++++++----- cptr/frontend/src/lib/i18n/locales/ja.json | 208 +++++++++++--- cptr/frontend/src/lib/i18n/locales/ko.json | 210 +++++++++++--- cptr/frontend/src/lib/i18n/locales/pt-BR.json | 250 +++++++++++----- cptr/frontend/src/lib/i18n/locales/ru.json | 220 ++++++++++---- cptr/frontend/src/lib/i18n/locales/zh-CN.json | 210 +++++++++++--- cptr/frontend/src/lib/i18n/locales/zh-TW.json | 210 +++++++++++--- .../src/routes/automations/+page.svelte | 3 +- .../src/routes/automations/[id]/+page.svelte | 3 +- 44 files changed, 1905 insertions(+), 713 deletions(-) diff --git a/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte b/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte index 5ed263f..57ffe39 100644 --- a/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte @@ -168,7 +168,7 @@ id={`${fieldPrefix}-home`} type="text" value={draft.home || ''} - placeholder="Optional" + placeholder={$t('admin.optional')} autocomplete="off" spellcheck="false" oninput={(e) => (draft.home = e.currentTarget.value || null)} @@ -203,7 +203,7 @@ id={`${fieldPrefix}-api-endpoint`} type="text" bind:value={draft.api_endpoint} - placeholder="Optional" + placeholder={$t('admin.optional')} autocomplete="off" spellcheck="false" class="block w-full bg-transparent text-[0.8125rem] text-gray-700 dark:text-gray-300 placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-none py-0.5 font-mono" @@ -221,7 +221,7 @@ id={`${fieldPrefix}-server-url`} type="text" bind:value={draft.server_url} - placeholder="Optional" + placeholder={$t('admin.optional')} autocomplete="off" spellcheck="false" class="block w-full bg-transparent text-[0.8125rem] text-gray-700 dark:text-gray-300 placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-none py-0.5 font-mono" @@ -237,7 +237,7 @@ id={`${fieldPrefix}-server-password`} type="password" bind:value={draft.server_password} - placeholder="Optional" + placeholder={$t('admin.optional')} autocomplete="off" spellcheck="false" class="block w-full bg-transparent text-[0.8125rem] text-gray-700 dark:text-gray-300 placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-none py-0.5 font-mono" diff --git a/cptr/frontend/src/lib/components/Admin/Agents.svelte b/cptr/frontend/src/lib/components/Admin/Agents.svelte index 6a97e67..5b20b12 100644 --- a/cptr/frontend/src/lib/components/Admin/Agents.svelte +++ b/cptr/frontend/src/lib/components/Admin/Agents.svelte @@ -310,7 +310,9 @@ {#if profiles.length === 0} -

No agent profiles

+

+ {$t('admin.agentsNoProfiles')} +

{/if}
diff --git a/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte b/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte index aab7bad..12da63d 100644 --- a/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/CreateConnectionModal.svelte @@ -82,7 +82,7 @@ >
- + - - + + {/if} diff --git a/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte b/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte index f53efdc..501a4ff 100644 --- a/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/EditConnectionModal.svelte @@ -118,7 +118,7 @@ >
- + - - + + {/if} diff --git a/cptr/frontend/src/lib/components/Admin/Models.svelte b/cptr/frontend/src/lib/components/Admin/Models.svelte index 959c60b..c052fe9 100644 --- a/cptr/frontend/src/lib/components/Admin/Models.svelte +++ b/cptr/frontend/src/lib/components/Admin/Models.svelte @@ -310,13 +310,13 @@ Files: )}
request params{$t('models.requestParams')} {#each rows as row, i}
onRemove(i)} class="shrink-0 text-gray-300 dark:text-gray-700 opacity-0 group-hover/row:opacity-100 hover:text-gray-500 dark:hover:text-gray-400 transition-colors duration-75" - aria-label="Remove" + aria-label={$t('common.remove')} > @@ -347,7 +347,7 @@ Files: onclick={onAdd} > - Add + {$t('common.add')}
{/snippet} diff --git a/cptr/frontend/src/lib/components/Bar.svelte b/cptr/frontend/src/lib/components/Bar.svelte index 7c6a758..264a28c 100644 --- a/cptr/frontend/src/lib/components/Bar.svelte +++ b/cptr/frontend/src/lib/components/Bar.svelte @@ -30,7 +30,7 @@ const direction = $activeWorkspace?.splitDirection ?? 'horizontal'; return [ { - label: 'Split Right', + label: $t('bar.splitRight'), icon: 'split-horizontal', active: direction === 'horizontal', onclick: () => { @@ -39,7 +39,7 @@ } }, { - label: 'Split Down', + label: $t('bar.splitDown'), icon: 'split-vertical', active: direction === 'vertical', onclick: () => { @@ -100,8 +100,8 @@ ? 'bg-gray-200 text-gray-900 dark:bg-white/8 dark:text-white' : 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}" onclick={() => (showSplitMenu = !showSplitMenu)} - aria-label="Split Editor" - use:tooltip={'Split Editor'} + aria-label={$t('a11y.splitEditor')} + use:tooltip={$t('a11y.splitEditor')} > diff --git a/cptr/frontend/src/lib/components/FileEditor.svelte b/cptr/frontend/src/lib/components/FileEditor.svelte index a17dc44..505ff57 100644 --- a/cptr/frontend/src/lib/components/FileEditor.svelte +++ b/cptr/frontend/src/lib/components/FileEditor.svelte @@ -2,6 +2,7 @@ import { onMount, onDestroy } from 'svelte'; import { clearTabEdit, markTabUnsaved, updateTabFilePath, activeWorkspace } from '$lib/stores'; import { get } from 'svelte/store'; + import { t } from '$lib/i18n'; import { tooltip } from '$lib/tooltip'; import { readFile, writeFile } from '$lib/apis/files'; import { getGitDiff } from '$lib/apis/git'; @@ -1210,7 +1211,7 @@ {:else if fileData?.binary}
-

Binary file

+

{$t('editor.binaryFile')}

{fileData.name} ({formatSize(fileData.size)})

{:else if diffMode} @@ -1219,8 +1220,8 @@
{:else if diffFiles.length === 0}
-

No changes

-

This file has no uncommitted modifications.

+

{$t('editor.noChanges')}

+

{$t('editor.noUncommittedModifications')}

{:else}
diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index d13531a..b3b3607 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -349,7 +349,7 @@ flash($t('git.uncommitted')); switchView('changes'); } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to undo commit'); + flash(e instanceof Error ? e.message : $t('git.uncommitFailed')); } loading = false; await refresh(); @@ -449,7 +449,7 @@ message?: string; }; if (!stashResult.ok) { - flash(stashResult.message || 'No changes stashed'); + flash(stashResult.message || $t('git.noChangesStashed')); return; } } @@ -457,7 +457,7 @@ pendingCheckoutBranch = null; await restoreStashedChangesForBranch(branch); } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to switch branch'); + flash(e instanceof Error ? e.message : $t('git.switchBranchFailed')); } finally { loading = false; await refresh(); @@ -493,7 +493,7 @@ await loadWorktrees(); } } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to create worktree'); + flash(e instanceof Error ? e.message : $t('git.createWorktreeFailed')); } finally { loading = false; } @@ -512,7 +512,7 @@ message?: string; }; if (!stashResult.ok) { - flash(stashResult.message || 'No changes stashed'); + flash(stashResult.message || $t('git.noChangesStashed')); return; } } @@ -522,7 +522,7 @@ showBranches = false; pendingCreateBranch = null; } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to create branch'); + flash(e instanceof Error ? e.message : $t('git.createBranchFailed')); } finally { loading = false; await refresh(); @@ -564,36 +564,36 @@ async function renameBranch(branch: BranchItem) { if (!branch.is_local) return; - const nextName = window.prompt('Rename branch', branch.name)?.trim(); + const nextName = window.prompt($t('git.renameBranch'), branch.name)?.trim(); if (!nextName || nextName === branch.name) return; try { await renameGitBranch(workspacePath, branch.name, nextName); - flash('Branch renamed'); + flash($t('git.branchRenamed')); closeBranchActionMenu(); await refresh({ force: true }); await loadBranches(); } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to rename branch'); + flash(e instanceof Error ? e.message : $t('git.renameBranchFailed')); } } function copyBranchName(branch: BranchItem) { navigator.clipboard.writeText(branch.name); - flash('Branch name copied'); + flash($t('git.branchNameCopied')); closeBranchActionMenu(); } async function deleteBranch(branch: BranchItem) { if (!branch.is_local || branch.is_current) return; - if (!confirm(`Delete branch "${branch.name}"?`)) return; + if (!confirm($t('git.deleteBranchConfirm', { name: branch.name }))) return; try { await deleteGitBranch(workspacePath, branch.name); - flash('Branch deleted'); + flash($t('git.branchDeleted')); closeBranchActionMenu(); await refresh({ force: true }); await loadBranches(); } catch (e) { - flash(e instanceof Error ? e.message : 'Failed to delete branch'); + flash(e instanceof Error ? e.message : $t('git.deleteBranchFailed')); } } @@ -864,7 +864,7 @@ { if (e.key === 'Escape') showBranches = false; @@ -884,7 +884,7 @@
- Branches + {$t('git.branches')}
{#each filteredBranches as branch (branch.name)}
{/if} {/snippet} @@ -1013,7 +1013,7 @@ { if (e.key === 'Escape') showWorktrees = false; @@ -1033,7 +1033,7 @@
- Worktrees + {$t('git.worktrees')}
{#each filteredWorktrees as worktree (worktree.path)}
{/if} {/if} @@ -1081,7 +1081,7 @@ bind:this={newWorktreeInputEl} type="text" class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white placeholder:text-gray-400" - placeholder="Branch name" + placeholder={$t('git.branchName')} bind:value={newWorktreeBranch} onkeydown={(e) => { if (e.key === 'Enter') createWorktree(); @@ -1117,7 +1117,7 @@ }} > - New worktree + {$t('git.newWorktree')} {/if} {/snippet} @@ -1331,7 +1331,7 @@ class="text-gray-400 dark:text-gray-600 shrink-0" /> - {unpushedCount} unpushed {unpushedCount === 1 ? 'commit' : 'commits'} + {$t('git.unpushedCommit', { count: unpushedCount })}
{/if} @@ -1345,7 +1345,7 @@ {#if i < unpushedCount} {/if}
@@ -1469,11 +1469,11 @@ {#if pendingCheckoutBranch} (pendingCheckoutBranch = null)} class="w-full max-w-sm mx-4">
-

Switch branches?

+

{$t('git.switchBranches')}

- You have {totalChanges} changed {totalChanges === 1 ? 'file' : 'files'} on - {gitStatus?.branch}. Choose - whether to leave those changes here or bring them to + {$t('git.moveChangesPromptPrefix', { count: totalChanges })} + {gitStatus?.branch}. + {$t('git.moveChangesPromptMiddle')} {pendingCheckoutBranch}.

@@ -1481,21 +1481,21 @@ class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors" onclick={() => (pendingCheckoutBranch = null)} > - Cancel + {$t('common.cancel')}
@@ -1505,11 +1505,13 @@ {#if pendingCreateBranch} (pendingCreateBranch = null)} class="w-full max-w-sm mx-4">
-

Create branch?

+

+ {$t('git.createBranchPrompt')} +

- You have {totalChanges} changed {totalChanges === 1 ? 'file' : 'files'} on - {gitStatus?.branch}. Choose - whether to leave those changes here or bring them to + {$t('git.moveChangesPromptPrefix', { count: totalChanges })} + {gitStatus?.branch}. + {$t('git.moveChangesPromptMiddle')} {pendingCreateBranch}.

@@ -1517,21 +1519,21 @@ class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors" onclick={() => (pendingCreateBranch = null)} > - Cancel + {$t('common.cancel')}
@@ -1545,21 +1547,21 @@ ...(branchActionMenu.branch.is_local ? [ { - label: 'Rename', + label: $t('files.rename'), icon: 'pencil', onclick: () => renameBranch(branchActionMenu!.branch) } ] : []), { - label: 'Copy branch name', + label: $t('git.copyBranchName'), icon: 'copy', onclick: () => copyBranchName(branchActionMenu!.branch) }, ...(branchActionMenu.branch.is_local && !branchActionMenu.branch.is_current ? [ { - label: 'Delete', + label: $t('files.delete'), icon: 'xmark', onclick: () => deleteBranch(branchActionMenu!.branch) } diff --git a/cptr/frontend/src/lib/components/GitView.svelte b/cptr/frontend/src/lib/components/GitView.svelte index f203444..78246c3 100644 --- a/cptr/frontend/src/lib/components/GitView.svelte +++ b/cptr/frontend/src/lib/components/GitView.svelte @@ -102,7 +102,7 @@ reviewFiles = nextFiles; } catch (e) { if (seq !== loadSeq) return; - error = e instanceof Error ? e.message : 'Failed to load git changes'; + error = e instanceof Error ? e.message : $t('git.loadChangesFailed'); reviewFiles = []; } finally { if (seq === loadSeq) { @@ -265,13 +265,15 @@ {:else if error && !gitStatus}
-

Unable to load changes

+

+ {$t('git.unableToLoadChanges')} +

{error}

{:else if !gitStatus?.is_repo}
-

Not a git repository

+

{$t('git.notARepo')}

{:else}
0} {totalChanges} changed{$t('git.changedCount', { count: totalChanges })} {/if}
@@ -325,11 +327,13 @@ onclick={toggleAll} > - {anyExpanded ? 'Collapse All' : 'Expand All'} + {anyExpanded ? $t('git.collapseAll') : $t('git.expandAll')} - Uncommitted + + {$t('git.uncommittedChanges')} + {totalChanges} {totalChanges === 1 ? 'change' : 'changes'}{$t('git.change', { count: totalChanges })}
{/if} @@ -345,10 +349,10 @@ class="text-gray-300 dark:text-gray-700" />

- No file changes yet + {$t('git.noFileChangesYet')}

- Changes in this project will appear here. + {$t('git.projectChangesHint')}

@@ -406,7 +410,7 @@ - {file.staged ? 'Staged' : 'Uncommitted'} + {file.staged ? $t('git.staged') : $t('git.uncommittedChanges')} @@ -462,7 +466,7 @@
- No textual diff available + {$t('git.noTextualDiff')}
{/if} diff --git a/cptr/frontend/src/lib/components/PortPreview.svelte b/cptr/frontend/src/lib/components/PortPreview.svelte index c1cbef4..c0fcdf6 100644 --- a/cptr/frontend/src/lib/components/PortPreview.svelte +++ b/cptr/frontend/src/lib/components/PortPreview.svelte @@ -126,7 +126,7 @@ class="preview-btn {canGoBack ? '' : 'disabled'}" onclick={goBack} disabled={!canGoBack} - use:tooltip={'Back'} + use:tooltip={$t('settings.back')} > @@ -136,13 +136,13 @@ class="preview-btn {canGoForward ? '' : 'disabled'}" onclick={goForward} disabled={!canGoForward} - use:tooltip={'Forward'} + use:tooltip={$t('common.forward')} > - @@ -159,7 +159,7 @@ - @@ -176,15 +176,15 @@ {#if loadError}

{$t('port.cannotConnect')}

-

localhost:{port} is not responding

- +

{$t('port.notResponding', { port })}

+
{:else} {#key iframeKey}