Skip to content

Commit c349413

Browse files
johnnyshieldsclaudesrc-opn
authored
feat(i18n): extract en translations — context/lib/misc (anomalyco#1251)
* feat(i18n): extract en translations for context/lib/misc Extract hardcoded English strings to i18n keys for: - automations context, providers store, shared-bundles - mcp-auth-modal, onboarding-workspace-selector, question-modal Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * feat(i18n): second pass — extract remaining hardcoded strings Fix missed strings not covered by reference diff: - automations: schedule_required, prompt_required, prompt_empty, server_unavailable in deleteScheduledJob, failed_to_load in local block, provider_id_required (2 missed instances in store.ts) - mcp-auth-modal: request_timed_out - question-modal: Submit/Next button labels (common.submit, common.next) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(i18n): drop stale rebase artifacts --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: src-opn <[email protected]>
1 parent f25911e commit c349413

5 files changed

Lines changed: 114 additions & 59 deletions

File tree

‎apps/app/src/app/components/mcp-auth-modal.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
168168
statusPoll = window.setInterval(async () => {
169169
if (Date.now() - startedAt >= MCP_AUTH_TIMEOUT_MS) {
170170
stopStatusPolling();
171-
setError("Request timed out.");
171+
setError(translate("mcp.auth.request_timed_out"));
172172
return;
173173
}
174174

@@ -694,7 +694,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
694694
<CheckCircle2 size={24} class="text-green-11" />
695695
</div>
696696
<div>
697-
<p class="text-sm font-medium text-gray-12">Already Connected</p>
697+
<p class="text-sm font-medium text-gray-12">{translate("mcp.auth.already_connected")}</p>
698698
<p class="text-xs text-gray-11">
699699
{translate("mcp.auth.already_connected_description", { server: serverName() })}
700700
</p>
@@ -804,7 +804,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
804804
</div>
805805
<div class="rounded-xl border border-gray-6/70 bg-gray-2/40 px-3 py-2 flex items-center gap-3">
806806
<div class="flex-1 min-w-0">
807-
<div class="text-[10px] uppercase tracking-wide text-gray-8">Authorization link</div>
807+
<div class="text-[10px] uppercase tracking-wide text-gray-8">{translate("mcp.auth.authorization_link")}</div>
808808
<div class="text-[11px] text-gray-11 font-mono truncate">
809809
{authorizationUrl()}
810810
</div>
@@ -814,7 +814,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
814814
class="text-xs"
815815
onClick={handleCopyAuthorizationUrl}
816816
>
817-
{authUrlCopied() ? "Copied" : "Copy link"}
817+
{authUrlCopied() ? translate("mcp.auth.copied") : translate("mcp.auth.copy_link")}
818818
</Button>
819819
</div>
820820
<TextInput
@@ -851,7 +851,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
851851
1
852852
</div>
853853
<div>
854-
<p class="text-sm font-medium text-gray-12">Opening your browser</p>
854+
<p class="text-sm font-medium text-gray-12">{translate("mcp.auth.step1_title")}</p>
855855
<p class="text-xs text-gray-10 mt-1">
856856
{translate("mcp.auth.step1_description", { server: serverName() })}
857857
</p>
@@ -863,7 +863,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
863863
2
864864
</div>
865865
<div>
866-
<p class="text-sm font-medium text-gray-12">Authorize OpenWork</p>
866+
<p class="text-sm font-medium text-gray-12">{translate("mcp.auth.step2_title")}</p>
867867
<p class="text-xs text-gray-10 mt-1">
868868
{translate("mcp.auth.step2_description")}
869869
</p>
@@ -875,7 +875,7 @@ export default function McpAuthModal(props: McpAuthModalProps) {
875875
3
876876
</div>
877877
<div>
878-
<p class="text-sm font-medium text-gray-12">Return here when you're done</p>
878+
<p class="text-sm font-medium text-gray-12">{translate("mcp.auth.step3_title")}</p>
879879
<p class="text-xs text-gray-10 mt-1">
880880
{translate("mcp.auth.step3_description")}
881881
</p>

‎apps/app/src/app/components/question-modal.tsx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { QuestionInfo } from "@opencode-ai/sdk/v2/client";
44
import { Check, ChevronRight, HelpCircle } from "lucide-solid";
55

66
import Button from "./button";
7+
import { t } from "../../i18n";
78

89
export type QuestionModalProps = {
910
open: boolean;
@@ -138,10 +139,10 @@ export default function QuestionModal(props: QuestionModalProps) {
138139
</div>
139140
<div>
140141
<h3 class="text-lg font-semibold text-gray-12">
141-
{currentQuestion()!.header || "Question"}
142+
{currentQuestion()!.header || t("common.question")}
142143
</h3>
143144
<div class="text-xs text-gray-11 font-medium">
144-
Question {currentIndex() + 1} of {props.questions.length}
145+
{t("question_modal.question_counter", undefined, { current: currentIndex() + 1, total: props.questions.length })}
145146
</div>
146147
</div>
147148
</div>
@@ -186,14 +187,14 @@ export default function QuestionModal(props: QuestionModalProps) {
186187
<Show when={currentQuestion()!.custom}>
187188
<div class="mt-4 pt-4 border-t border-dls-border">
188189
<label class="block text-xs font-semibold text-dls-secondary mb-2 uppercase tracking-wide">
189-
Or type a custom answer
190+
{t("question_modal.custom_answer_label")}
190191
</label>
191192
<input
192193
type="text"
193194
value={customInput()}
194195
onInput={(e) => setCustomInput(e.currentTarget.value)}
195196
class="w-full px-4 py-3 rounded-xl bg-dls-surface border border-dls-border focus:border-dls-accent focus:ring-4 focus:ring-[rgba(var(--dls-accent-rgb),0.2)] focus:outline-none text-sm text-dls-text placeholder:text-dls-secondary transition-shadow"
196-
placeholder="Type your answer here..."
197+
placeholder={t("question_modal.custom_answer_placeholder")}
197198
onKeyDown={(e) => {
198199
if (e.key === "Enter") {
199200
if (e.isComposing || e.keyCode === 229) return;
@@ -209,15 +210,15 @@ export default function QuestionModal(props: QuestionModalProps) {
209210
<div class="p-6 border-t border-dls-border bg-dls-hover flex justify-between items-center">
210211
<div class="text-xs text-dls-secondary flex items-center gap-2">
211212
<span class="px-1.5 py-0.5 rounded border border-dls-border bg-dls-active font-mono">↑↓</span>
212-
<span>navigate</span>
213+
<span>{t("common.navigate")}</span>
213214
<span class="px-1.5 py-0.5 rounded border border-gray-6 bg-gray-3 font-mono ml-2">↵</span>
214-
<span>select</span>
215+
<span>{t("common.select")}</span>
215216
</div>
216217

217218
<div class="flex gap-2">
218219
<Show when={currentQuestion()?.multiple || currentQuestion()?.custom}>
219220
<Button onClick={handleNext} disabled={!canProceed() || props.busy} class="!px-6">
220-
{isLastQuestion() ? "Submit" : "Next"}
221+
{isLastQuestion() ? t("common.submit") : t("common.next")}
221222
<Show when={!isLastQuestion()}>
222223
<ChevronRight size={16} class="ml-1 -mr-1 opacity-60" />
223224
</Show>

‎apps/app/src/app/context/automations.ts‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { schedulerDeleteJob, schedulerListJobs } from "../lib/tauri";
55
import { isTauriRuntime } from "../utils";
66
import { createWorkspaceContextKey } from "./workspace-context";
77
import type { OpenworkServerStore } from "../connections/openwork-server-store";
8+
import { t } from "../../i18n";
89

910
export type AutomationsStore = ReturnType<typeof createAutomationsStore>;
1011

@@ -33,10 +34,10 @@ const buildCreateAutomationPrompt = (
3334
const schedule = input.schedule.trim();
3435
const prompt = normalizeSentence(input.prompt);
3536
if (!schedule) {
36-
return { ok: false, error: "Schedule is required." };
37+
return { ok: false, error: t("automations.schedule_required") };
3738
}
3839
if (!prompt) {
39-
return { ok: false, error: "Prompt is required." };
40+
return { ok: false, error: t("automations.prompt_required") };
4041
}
4142
const workdir = (input.workdir ?? "").trim();
4243
const nameSegment = name ? ` named \"${name}\"` : "";
@@ -58,7 +59,7 @@ const buildRunAutomationPrompt = (
5859
if (job.run?.prompt || job.prompt) {
5960
const promptBody = (job.run?.prompt ?? job.prompt ?? "").trim();
6061
if (!promptBody) {
61-
return { ok: false, error: "Automation prompt is empty." };
62+
return { ok: false, error: t("automations.prompt_empty") };
6263
}
6364
return {
6465
ok: true,
@@ -136,10 +137,10 @@ export function createAutomationsStore(options: {
136137
if (scheduledJobsContextKey() !== requestContextKey) return "skipped";
137138
const status =
138139
options.openworkServer.openworkServerStatus() === "disconnected"
139-
? "OpenWork server unavailable. Connect to sync scheduled tasks."
140+
? t("automations.server_unavailable")
140141
: options.openworkServer.openworkServerStatus() === "limited"
141-
? "OpenWork server needs a token to load scheduled tasks."
142-
: "OpenWork server not ready.";
142+
? t("automations.server_needs_token")
143+
: t("automations.server_not_ready");
143144
setScheduledJobsStatus(status);
144145
return "unavailable";
145146
}
@@ -155,7 +156,7 @@ export function createAutomationsStore(options: {
155156
} catch (error) {
156157
if (scheduledJobsContextKey() !== requestContextKey) return "skipped";
157158
const message = error instanceof Error ? error.message : String(error);
158-
setScheduledJobsStatus(message || "Failed to load scheduled tasks.");
159+
setScheduledJobsStatus(message || t("automations.failed_to_load"));
159160
return "error";
160161
} finally {
161162
setScheduledJobsBusy(false);
@@ -180,7 +181,7 @@ export function createAutomationsStore(options: {
180181
} catch (error) {
181182
if (scheduledJobsContextKey() !== requestContextKey) return "skipped";
182183
const message = error instanceof Error ? error.message : String(error);
183-
setScheduledJobsStatus(message || "Failed to load scheduled tasks.");
184+
setScheduledJobsStatus(message || t("automations.failed_to_load"));
184185
return "error";
185186
} finally {
186187
setScheduledJobsBusy(false);
@@ -192,15 +193,15 @@ export function createAutomationsStore(options: {
192193
const client = options.openworkServer.openworkServerClient();
193194
const workspaceId = (options.runtimeWorkspaceId() ?? "").trim();
194195
if (!client || !workspaceId) {
195-
throw new Error("OpenWork server unavailable. Connect to sync scheduled tasks.");
196+
throw new Error(t("automations.server_unavailable"));
196197
}
197198
const response = await client.deleteScheduledJob(workspaceId, name);
198199
setScheduledJobs((current) => current.filter((entry) => entry.slug !== response.job.slug));
199200
return;
200201
}
201202

202203
if (!isTauriRuntime()) {
203-
throw new Error("Scheduled tasks require the desktop app.");
204+
throw new Error(t("automations.desktop_required"));
204205
}
205206
const root = options.selectedWorkspaceRoot().trim();
206207
const job = await schedulerDeleteJob(name, root || undefined);

0 commit comments

Comments
 (0)