@juicesharp/rpiv-ask-user-question 1.0.19 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,6 +24,7 @@ Let the model ask you structured clarifying questions instead of guessing. `rpiv
24
24
  - **Submit tab** — review every answer before submitting; warns about unanswered questions and offers a Submit picker.
25
25
  - **Chat row on every tab** — redirect the conversation without leaving the dialog.
26
26
  - **"Other" free-text fallback** — type a custom answer when no option fits.
27
+ - **Localized UI** — sentinel rows, hints, submit/cancel labels, review pane, and notes affordance display in the user's chosen language via `@juicesharp/rpiv-i18n`. Ships Deutsch / English / Español / Français / Português (PT) / Português (BR) / Русский / Українська; switch with `/languages` or `pi --locale <code>`. LLM-facing copy (tool description, schemas, errors) stays English by design.
27
28
 
28
29
  ## Screens
29
30
 
@@ -31,6 +32,7 @@ Let the model ask you structured clarifying questions instead of guessing. `rpiv
31
32
  |---|---|
32
33
  | ![Single-question dialog](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/single-question.jpg) | ![Multi-tab + ASCII preview](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/multi-tab-preview.jpg) |
33
34
  | ![Multi-select with checkboxes](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/multi-select.jpg) | ![Submit tab review](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/submit-tab.jpg) |
35
+ | ![Localized UI — German](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/localized-german-ui.jpg) | |
34
36
 
35
37
  ## Install
36
38
 
@@ -1,6 +1,7 @@
1
1
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ import { displayLabel } from "./state/i18n-bridge.js";
2
3
  import { QuestionnaireSession } from "./state/questionnaire-session.js";
3
- import { ROW_INTENT_META, sentinelsToAppend } from "./state/row-intent.js";
4
+ import { sentinelsToAppend } from "./state/row-intent.js";
4
5
  import { buildQuestionnaireResponse, buildToolResult } from "./tool/response-envelope.js";
5
6
  import {
6
7
  MAX_OPTIONS,
@@ -24,7 +25,7 @@ export function buildItemsForQuestion(question: QuestionData): WrappingSelectIte
24
25
  }));
25
26
  const hasAnyPreview = question.options.some((o) => typeof o.preview === "string" && o.preview.length > 0);
26
27
  for (const kind of sentinelsToAppend(question, hasAnyPreview)) {
27
- items.push({ kind, label: ROW_INTENT_META[kind].label });
28
+ items.push({ kind, label: displayLabel(kind) });
28
29
  }
29
30
  return items;
30
31
  }
package/index.ts CHANGED
@@ -1,10 +1,52 @@
1
1
  /**
2
2
  * rpiv-ask-user-question — Pi extension. Registers the `ask_user_question`
3
3
  * tool: a structured option selector with a free-text "Other" fallback.
4
+ *
5
+ * Sentinel labels (and TUI chrome strings in subsequent phases) localize at
6
+ * render time via the i18n bridge. Strings are registered with rpiv-i18n
7
+ * here, once, at module init.
8
+ *
9
+ * Adding a locale: drop `locales/<code>.json` next to en.json (mirroring the
10
+ * key set), then add the load + entry to the `registerStrings` call below.
11
+ * See `@juicesharp/rpiv-i18n` README → "Contributing translations" for the
12
+ * full convention.
4
13
  */
5
14
 
15
+ import { readFileSync } from "node:fs";
16
+ import { fileURLToPath } from "node:url";
17
+ import { registerStrings, type TranslationMap } from "@juicesharp/rpiv-i18n";
6
18
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
7
19
  import { registerAskUserQuestionTool } from "./ask-user-question.js";
20
+ import { I18N_NAMESPACE } from "./state/i18n-bridge.js";
21
+
22
+ function loadLocale(code: string): TranslationMap {
23
+ // A missing or malformed locale file degrades gracefully: registerStrings
24
+ // records an empty map for the locale, so render-time `tr(key, fallback)`
25
+ // returns the canonical English literal at the call site. Crashing here
26
+ // would take the entire ask_user_question tool offline at module init —
27
+ // publish-manifest miss would brick the extension.
28
+ try {
29
+ return JSON.parse(
30
+ readFileSync(fileURLToPath(new URL(`./locales/${code}.json`, import.meta.url)), "utf-8"),
31
+ ) as TranslationMap;
32
+ } catch (err) {
33
+ console.warn(
34
+ `rpiv-ask-user-question: failed to load locales/${code}.json — falling back to English (${(err as Error).message})`,
35
+ );
36
+ return {};
37
+ }
38
+ }
39
+
40
+ registerStrings(I18N_NAMESPACE, {
41
+ de: loadLocale("de"),
42
+ en: loadLocale("en"),
43
+ es: loadLocale("es"),
44
+ fr: loadLocale("fr"),
45
+ pt: loadLocale("pt"),
46
+ "pt-BR": loadLocale("pt-BR"),
47
+ ru: loadLocale("ru"),
48
+ uk: loadLocale("uk"),
49
+ });
8
50
 
9
51
  export default function (pi: ExtensionAPI) {
10
52
  registerAskUserQuestionTool(pi);
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Schreibe etwas.",
5
+ "sentinel.chat": "Darüber chatten",
6
+ "sentinel.next": "Weiter",
7
+
8
+ "submit.label": "Antworten senden",
9
+ "submit.cancel": "Abbrechen",
10
+
11
+ "hint.enter": "Enter zum Auswählen",
12
+ "hint.navigate": "↑/↓ zur Navigation",
13
+ "hint.toggle": "Leertaste zum Umschalten",
14
+ "hint.notes": "n für Notizen",
15
+ "hint.tab": "Tab wechselt die Frage",
16
+ "hint.cancel": "Esc zum Abbrechen",
17
+
18
+ "review.heading": "Antworten überprüfen",
19
+ "review.ready": "Bereit, deine Antworten zu senden?",
20
+ "review.incomplete": "⚠ Beantworte die verbleibenden Fragen vor dem Senden:",
21
+
22
+ "preview.no_preview": "Keine Vorschau verfügbar",
23
+ "preview.notes_affordance": "Notizen: drücke n, um Notizen hinzuzufügen",
24
+
25
+ "chat.summary": "Benutzer möchte darüber chatten",
26
+ "notes.header": "Notizen:"
27
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "sentinel.other": "Type something.",
3
+ "sentinel.chat": "Chat about this",
4
+ "sentinel.next": "Next",
5
+
6
+ "submit.label": "Submit answers",
7
+ "submit.cancel": "Cancel",
8
+
9
+ "hint.enter": "Enter to select",
10
+ "hint.navigate": "↑/↓ to navigate",
11
+ "hint.toggle": "Space to toggle",
12
+ "hint.notes": "n to add notes",
13
+ "hint.tab": "Tab to switch questions",
14
+ "hint.cancel": "Esc to cancel",
15
+
16
+ "review.heading": "Review your answers",
17
+ "review.ready": "Ready to submit your answers?",
18
+ "review.incomplete": "⚠ Answer remaining questions before submitting:",
19
+
20
+ "preview.no_preview": "No preview available",
21
+ "preview.notes_affordance": "Notes: press n to add notes",
22
+
23
+ "chat.summary": "User wants to chat about this",
24
+ "notes.header": "Notes:"
25
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Escribe algo.",
5
+ "sentinel.chat": "Conversar sobre esto",
6
+ "sentinel.next": "Siguiente",
7
+
8
+ "submit.label": "Enviar respuestas",
9
+ "submit.cancel": "Cancelar",
10
+
11
+ "hint.enter": "Enter para seleccionar",
12
+ "hint.navigate": "↑/↓ para navegar",
13
+ "hint.toggle": "Espacio para alternar",
14
+ "hint.notes": "n para añadir notas",
15
+ "hint.tab": "Tab para cambiar de pregunta",
16
+ "hint.cancel": "Esc para cancelar",
17
+
18
+ "review.heading": "Revisa tus respuestas",
19
+ "review.ready": "¿Listo para enviar tus respuestas?",
20
+ "review.incomplete": "⚠ Responde las preguntas restantes antes de enviar:",
21
+
22
+ "preview.no_preview": "Vista previa no disponible",
23
+ "preview.notes_affordance": "Notas: pulsa n para añadir notas",
24
+
25
+ "chat.summary": "El usuario quiere conversar sobre esto",
26
+ "notes.header": "Notas:"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Écrivez quelque chose.",
5
+ "sentinel.chat": "Discuter de ceci",
6
+ "sentinel.next": "Suivant",
7
+
8
+ "submit.label": "Envoyer les réponses",
9
+ "submit.cancel": "Annuler",
10
+
11
+ "hint.enter": "Entrée pour sélectionner",
12
+ "hint.navigate": "↑/↓ pour naviguer",
13
+ "hint.toggle": "Espace pour basculer",
14
+ "hint.notes": "n pour ajouter des notes",
15
+ "hint.tab": "Tab pour changer de question",
16
+ "hint.cancel": "Échap pour annuler",
17
+
18
+ "review.heading": "Vérifiez vos réponses",
19
+ "review.ready": "Prêt à envoyer vos réponses ?",
20
+ "review.incomplete": "⚠ Répondez aux questions restantes avant d'envoyer :",
21
+
22
+ "preview.no_preview": "Aucun aperçu disponible",
23
+ "preview.notes_affordance": "Notes : appuyez sur n pour ajouter des notes",
24
+
25
+ "chat.summary": "L'utilisateur souhaite discuter de ceci",
26
+ "notes.header": "Notes :"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Digite algo.",
5
+ "sentinel.chat": "Conversar sobre isso",
6
+ "sentinel.next": "Próximo",
7
+
8
+ "submit.label": "Enviar respostas",
9
+ "submit.cancel": "Cancelar",
10
+
11
+ "hint.enter": "Enter para selecionar",
12
+ "hint.navigate": "↑/↓ para navegar",
13
+ "hint.toggle": "Espaço para alternar",
14
+ "hint.notes": "n para adicionar notas",
15
+ "hint.tab": "Tab para trocar de pergunta",
16
+ "hint.cancel": "Esc para cancelar",
17
+
18
+ "review.heading": "Revise suas respostas",
19
+ "review.ready": "Pronto para enviar suas respostas?",
20
+ "review.incomplete": "⚠ Responda as perguntas restantes antes de enviar:",
21
+
22
+ "preview.no_preview": "Pré-visualização indisponível",
23
+ "preview.notes_affordance": "Notas: pressione n para adicionar notas",
24
+
25
+ "chat.summary": "O usuário quer conversar sobre isso",
26
+ "notes.header": "Notas:"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "European Portuguese (Portugal). Auto-translated draft. Native-speaker review welcome via PR. Distinct from pt-BR (Brasil): differs in lexicon (utilizador / você), conjugation, and some terms. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Escreva algo.",
5
+ "sentinel.chat": "Conversar sobre isto",
6
+ "sentinel.next": "Seguinte",
7
+
8
+ "submit.label": "Enviar respostas",
9
+ "submit.cancel": "Cancelar",
10
+
11
+ "hint.enter": "Enter para selecionar",
12
+ "hint.navigate": "↑/↓ para navegar",
13
+ "hint.toggle": "Espaço para alternar",
14
+ "hint.notes": "n para adicionar notas",
15
+ "hint.tab": "Tab para mudar de pergunta",
16
+ "hint.cancel": "Esc para cancelar",
17
+
18
+ "review.heading": "Reveja as suas respostas",
19
+ "review.ready": "Pronto para enviar as suas respostas?",
20
+ "review.incomplete": "⚠ Responda às perguntas restantes antes de enviar:",
21
+
22
+ "preview.no_preview": "Pré-visualização indisponível",
23
+ "preview.notes_affordance": "Notas: prima n para adicionar notas",
24
+
25
+ "chat.summary": "O utilizador quer conversar sobre isto",
26
+ "notes.header": "Notas:"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Введите что-нибудь.",
5
+ "sentinel.chat": "Обсудить это",
6
+ "sentinel.next": "Далее",
7
+
8
+ "submit.label": "Отправить ответы",
9
+ "submit.cancel": "Отмена",
10
+
11
+ "hint.enter": "Enter — выбрать",
12
+ "hint.navigate": "↑/↓ — навигация",
13
+ "hint.toggle": "Space — переключить",
14
+ "hint.notes": "n — добавить заметки",
15
+ "hint.tab": "Tab — следующий вопрос",
16
+ "hint.cancel": "Esc — отменить",
17
+
18
+ "review.heading": "Проверьте свои ответы",
19
+ "review.ready": "Готовы отправить ответы?",
20
+ "review.incomplete": "⚠ Ответьте на оставшиеся вопросы перед отправкой:",
21
+
22
+ "preview.no_preview": "Предпросмотр недоступен",
23
+ "preview.notes_affordance": "Заметки: нажмите n, чтобы добавить заметки",
24
+
25
+ "chat.summary": "Пользователь хочет обсудить это",
26
+ "notes.header": "Заметки:"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n) are universal CLI conventions and stay untranslated.",
3
+
4
+ "sentinel.other": "Введіть щось.",
5
+ "sentinel.chat": "Обговорити це",
6
+ "sentinel.next": "Далі",
7
+
8
+ "submit.label": "Надіслати відповіді",
9
+ "submit.cancel": "Скасувати",
10
+
11
+ "hint.enter": "Enter — обрати",
12
+ "hint.navigate": "↑/↓ — навігація",
13
+ "hint.toggle": "Space — перемкнути",
14
+ "hint.notes": "n — додати нотатки",
15
+ "hint.tab": "Tab — наступне питання",
16
+ "hint.cancel": "Esc — скасувати",
17
+
18
+ "review.heading": "Перегляньте свої відповіді",
19
+ "review.ready": "Готові надіслати відповіді?",
20
+ "review.incomplete": "⚠ Дайте відповіді на решту питань перед надсиланням:",
21
+
22
+ "preview.no_preview": "Попередній перегляд недоступний",
23
+ "preview.notes_affordance": "Нотатки: натисніть n, щоб додати нотатки",
24
+
25
+ "chat.summary": "Користувач хоче обговорити це",
26
+ "notes.header": "Нотатки:"
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-ask-user-question",
3
- "version": "1.0.19",
3
+ "version": "1.1.0",
4
4
  "description": "Pi extension: lets the model ask you a clarifying question with structured options instead of guessing",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -29,8 +29,10 @@
29
29
  "ask-user-question.ts",
30
30
  "index.ts",
31
31
  "LICENSE",
32
+ "locales/",
32
33
  "README.md",
33
34
  "state/build-questionnaire.ts",
35
+ "state/i18n-bridge.ts",
34
36
  "state/key-router.ts",
35
37
  "state/questionnaire-session.ts",
36
38
  "state/row-intent.ts",
@@ -69,6 +71,7 @@
69
71
  ]
70
72
  },
71
73
  "peerDependencies": {
74
+ "@juicesharp/rpiv-i18n": "*",
72
75
  "@mariozechner/pi-coding-agent": "*",
73
76
  "@mariozechner/pi-tui": "*",
74
77
  "typebox": "*"
@@ -1,6 +1,6 @@
1
1
  import { getMarkdownTheme, type Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { Input } from "@mariozechner/pi-tui";
3
- import { type QuestionData, SENTINEL_LABELS } from "../tool/types.js";
3
+ import type { QuestionData } from "../tool/types.js";
4
4
  import {
5
5
  type BoundGlobalBinding,
6
6
  type BoundPerTabBinding,
@@ -20,6 +20,7 @@ import { DialogView } from "../view/dialog-builder.js";
20
20
  import { QuestionnairePropsAdapter } from "../view/props-adapter.js";
21
21
  import type { StatefulView } from "../view/stateful-view.js";
22
22
  import type { TabBodyHeights, TabComponents } from "../view/tab-components.js";
23
+ import { displayLabel } from "./i18n-bridge.js";
23
24
  import type { PerTabSelector } from "./selectors/contract.js";
24
25
  import { selectActivePreviewPaneIndex } from "./selectors/derivations.js";
25
26
  import {
@@ -116,7 +117,7 @@ class QuestionnaireBuilder {
116
117
 
117
118
  this.selectTheme = this.makeSelectTheme();
118
119
  this.chatRow = new ChatRowView({
119
- item: { kind: "chat", label: SENTINEL_LABELS.chat },
120
+ item: { kind: "chat", label: displayLabel("chat") },
120
121
  theme: this.selectTheme,
121
122
  });
122
123
  }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * i18n bridge for rpiv-ask-user-question — single thin import surface so every
3
+ * call site routes through one place. Backed by `@juicesharp/rpiv-i18n`'s SDK.
4
+ *
5
+ * - `t(key, fallback)` is `scope("@juicesharp/rpiv-ask-user-question")`.
6
+ * - `displayLabel(kind)` resolves a sentinel kind to its locale-aware label,
7
+ * with the canonical English `ROW_INTENT_META[kind].label` as fallback so
8
+ * nothing renders blank if the namespace isn't registered.
9
+ *
10
+ * Strings are registered ONCE at extension load (see ../index.ts). Call sites
11
+ * MUST use this module at render time — never bake the result into a top-level
12
+ * `const X = displayLabel(...)`.
13
+ *
14
+ * Reserved-label validation stays English-locked: `RESERVED_LABEL_SET` checks
15
+ * the canonical `ROW_INTENT_META[kind].label`, never `displayLabel(kind)`.
16
+ */
17
+
18
+ import { scope } from "@juicesharp/rpiv-i18n";
19
+ import { ROW_INTENT_META, type SentinelKind } from "./row-intent.js";
20
+
21
+ export const I18N_NAMESPACE = "@juicesharp/rpiv-ask-user-question";
22
+
23
+ export const t = scope(I18N_NAMESPACE);
24
+
25
+ export function displayLabel(kind: SentinelKind): string {
26
+ return t(`sentinel.${kind}`, ROW_INTENT_META[kind].label);
27
+ }
@@ -1,9 +1,10 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { getKeybindings, type Input } from "@mariozechner/pi-tui";
3
- import { type QuestionData, type QuestionnaireResult, type QuestionParams, SENTINEL_LABELS } from "../tool/types.js";
3
+ import type { QuestionData, QuestionnaireResult, QuestionParams } from "../tool/types.js";
4
4
  import type { WrappingSelectItem } from "../view/components/wrapping-select.js";
5
5
  import type { QuestionnairePropsAdapter } from "../view/props-adapter.js";
6
6
  import { buildQuestionnaire } from "./build-questionnaire.js";
7
+ import { displayLabel } from "./i18n-bridge.js";
7
8
  import { type QuestionnaireAction, routeKey } from "./key-router.js";
8
9
  import { computeFocusedOptionHasPreview } from "./selectors/derivations.js";
9
10
  import type { QuestionnaireRuntime, QuestionnaireState } from "./state.js";
@@ -181,9 +182,9 @@ export class QuestionnaireSession {
181
182
  }
182
183
 
183
184
  private currentItem(): WrappingSelectItem | undefined {
184
- if (this.state.chatFocused) return { kind: "chat", label: SENTINEL_LABELS.chat };
185
+ if (this.state.chatFocused) return { kind: "chat", label: displayLabel("chat") };
185
186
  const arr = this.itemsByTab[this.state.currentTab] ?? [];
186
187
  if (this.state.optionIndex < arr.length) return arr[this.state.optionIndex];
187
- return { kind: "chat", label: SENTINEL_LABELS.chat };
188
+ return { kind: "chat", label: displayLabel("chat") };
188
189
  }
189
190
  }
@@ -1,4 +1,3 @@
1
- import { SENTINEL_LABELS } from "../../tool/types.js";
2
1
  import type { ChatRowViewProps } from "../../view/components/chat-row-view.js";
3
2
  import { MULTI_SUBMIT_LABEL, type MultiSelectViewProps } from "../../view/components/multi-select-view.js";
4
3
  import type { OptionListViewProps } from "../../view/components/option-list-view.js";
@@ -6,12 +5,13 @@ import type { PreviewPaneProps } from "../../view/components/preview/preview-pan
6
5
  import type { SubmitPickerProps } from "../../view/components/submit-picker.js";
7
6
  import type { TabBarProps } from "../../view/components/tab-bar.js";
8
7
  import type { DialogProps } from "../../view/dialog-builder.js";
8
+ import { displayLabel } from "../i18n-bridge.js";
9
9
  import type { GlobalSelector, PerTabSelector } from "./contract.js";
10
10
  import { chatNumberingFor, selectActiveTabItems, selectConfirmedIndicator } from "./derivations.js";
11
11
 
12
12
  export const selectMultiSelectProps: PerTabSelector<MultiSelectViewProps> = (state, ctx) => {
13
13
  const question = ctx.questions[ctx.i];
14
- if (!question) return { rows: [], nextActive: false, nextLabel: SENTINEL_LABELS.next };
14
+ if (!question) return { rows: [], nextActive: false, nextLabel: displayLabel("next") };
15
15
  const focused = ctx.activeView === "options";
16
16
  const rows: { checked: boolean; active: boolean }[] = [];
17
17
  for (let i = 0; i < question.options.length; i++) {
@@ -22,7 +22,7 @@ export const selectMultiSelectProps: PerTabSelector<MultiSelectViewProps> = (sta
22
22
  }
23
23
  const nextActive = focused && state.optionIndex === question.options.length;
24
24
  const isLastQuestion = ctx.i === ctx.questions.length - 1;
25
- const nextLabel = isLastQuestion ? MULTI_SUBMIT_LABEL : SENTINEL_LABELS.next;
25
+ const nextLabel = isLastQuestion ? MULTI_SUBMIT_LABEL : displayLabel("next");
26
26
  return { rows, nextActive, nextLabel };
27
27
  };
28
28
 
@@ -1,3 +1,4 @@
1
+ import { t } from "../state/i18n-bridge.js";
1
2
  import type { QuestionAnswer } from "./types.js";
2
3
 
3
4
  /**
@@ -35,7 +36,7 @@ export type FormatAnswerVariant = "summary" | "envelope";
35
36
  export function formatAnswerScalar(a: QuestionAnswer, variant: FormatAnswerVariant): string {
36
37
  switch (a.kind) {
37
38
  case "chat":
38
- return variant === "envelope" ? CHAT_CONTINUATION_MESSAGE : CHAT_SUMMARY_MESSAGE;
39
+ return variant === "envelope" ? CHAT_CONTINUATION_MESSAGE : t("chat.summary", CHAT_SUMMARY_MESSAGE);
39
40
  case "multi":
40
41
  return a.selected && a.selected.length > 0 ? a.selected.join(", ") : NO_INPUT_PLACEHOLDER;
41
42
  case "custom":
@@ -1,6 +1,7 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@mariozechner/pi-tui";
3
- import { type QuestionData, SENTINEL_LABELS } from "../../tool/types.js";
3
+ import { displayLabel } from "../../state/i18n-bridge.js";
4
+ import type { QuestionData } from "../../tool/types.js";
4
5
  import type { StatefulView } from "../stateful-view.js";
5
6
 
6
7
  const ACTIVE_POINTER = "❯ ";
@@ -38,7 +39,7 @@ export class MultiSelectView implements StatefulView<MultiSelectViewProps> {
38
39
  private readonly theme: Theme,
39
40
  private readonly question: QuestionData,
40
41
  ) {
41
- this.props = { rows: [], nextActive: false, nextLabel: SENTINEL_LABELS.next };
42
+ this.props = { rows: [], nextActive: false, nextLabel: displayLabel("next") };
42
43
  }
43
44
 
44
45
  setProps(props: MultiSelectViewProps): void {
@@ -1,5 +1,6 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { Markdown, type MarkdownTheme, visibleWidth } from "@mariozechner/pi-tui";
3
+ import { t } from "../../../state/i18n-bridge.js";
3
4
  import type { QuestionData } from "../../../tool/types.js";
4
5
  import { stripFenceMarkers } from "./preview-box-renderer.js";
5
6
 
@@ -57,7 +58,7 @@ export class MarkdownContentCache {
57
58
  }
58
59
  const text = this.previewTexts.get(optionIndex);
59
60
  if (!text) {
60
- const placeholder = this.theme.fg("dim", NO_PREVIEW_TEXT);
61
+ const placeholder = this.theme.fg("dim", t("preview.no_preview", NO_PREVIEW_TEXT));
61
62
  const pad = Math.max(0, innerWidth - visibleWidth(placeholder));
62
63
  return [placeholder + " ".repeat(pad)];
63
64
  }
@@ -1,5 +1,6 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import type { MarkdownTheme } from "@mariozechner/pi-tui";
3
+ import { t } from "../../../state/i18n-bridge.js";
3
4
  import type { QuestionData } from "../../../tool/types.js";
4
5
  import {
5
6
  MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,
@@ -100,7 +101,9 @@ export class PreviewBlockRenderer {
100
101
  const boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);
101
102
 
102
103
  const showAffordance = focused && !notesVisible && this.cache.has(optionIndex);
103
- const affordance = showAffordance ? this.theme.fg("muted", NOTES_AFFORDANCE_TEXT) : "";
104
+ const affordance = showAffordance
105
+ ? this.theme.fg("muted", t("preview.notes_affordance", NOTES_AFFORDANCE_TEXT))
106
+ : "";
104
107
  return [...boxedLines, "", affordance];
105
108
  }
106
109
  }
@@ -1,5 +1,6 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { truncateToWidth } from "@mariozechner/pi-tui";
3
+ import { t } from "../../state/i18n-bridge.js";
3
4
  import type { StatefulView } from "../stateful-view.js";
4
5
 
5
6
  const ACTIVE_POINTER = "❯ ";
@@ -52,7 +53,7 @@ export class SubmitPicker implements StatefulView<SubmitPickerProps> {
52
53
  render(width: number): string[] {
53
54
  const lines: string[] = [];
54
55
  for (let i = 0; i < 2; i++) {
55
- const text = i === 0 ? SUBMIT_LABEL : CANCEL_LABEL;
56
+ const text = i === 0 ? t("submit.label", SUBMIT_LABEL) : t("submit.cancel", CANCEL_LABEL);
56
57
  const active = this.props.rows[i]?.active ?? false;
57
58
  const pointer = active ? ACTIVE_POINTER : INACTIVE_POINTER;
58
59
  const number = `${i + 1}${NUMBER_SEPARATOR}`;
@@ -1,5 +1,6 @@
1
1
  import type { Theme } from "@mariozechner/pi-coding-agent";
2
2
  import { type Component, Container, type Input, Spacer, Text } from "@mariozechner/pi-tui";
3
+ import { t } from "../state/i18n-bridge.js";
3
4
  import { formatAnswerScalar } from "../tool/format-answer.js";
4
5
  import type { QuestionData } from "../tool/types.js";
5
6
  import type { ChatRowView } from "./components/chat-row-view.js";
@@ -19,6 +20,8 @@ import {
19
20
  import type { StatefulView } from "./stateful-view.js";
20
21
  import type { TabComponents } from "./tab-components.js";
21
22
 
23
+ const NOTES_HEADER = "Notes:";
24
+
22
25
  /**
23
26
  * Per-tab content provider. Pure functional — closes over construction-time
24
27
  * config; per-tick state threads through method args. The chrome wrapper
@@ -89,7 +92,11 @@ export class QuestionTabStrategy implements TabContentStrategy {
89
92
 
90
93
  midRows(state: DialogState): Component[] {
91
94
  if (!state.notesVisible) return [];
92
- return [new Text(this.config.theme.fg("muted", "Notes:"), 1, 0), this.config.notesInput, new Spacer(1)];
95
+ return [
96
+ new Text(this.config.theme.fg("muted", t("notes.header", NOTES_HEADER)), 1, 0),
97
+ this.config.notesInput,
98
+ new Spacer(1),
99
+ ];
93
100
  }
94
101
 
95
102
  footerRows(state: DialogState): Component[] {
@@ -116,7 +123,10 @@ export class SubmitTabStrategy implements TabContentStrategy {
116
123
  constructor(private readonly config: SubmitTabStrategyConfig) {}
117
124
 
118
125
  headingRows(_state: DialogState): Component[] {
119
- return [new Text(this.config.theme.bold(this.config.theme.fg("accent", REVIEW_HEADING)), 1, 0), new Spacer(1)];
126
+ return [
127
+ new Text(this.config.theme.bold(this.config.theme.fg("accent", t("review.heading", REVIEW_HEADING))), 1, 0),
128
+ new Spacer(1),
129
+ ];
120
130
  }
121
131
 
122
132
  bodyComponent(state: DialogState): Component {
@@ -156,8 +166,11 @@ export class SubmitTabStrategy implements TabContentStrategy {
156
166
  }
157
167
  const promptText =
158
168
  missing.length === 0
159
- ? this.config.theme.fg("muted", READY_PROMPT)
160
- : this.config.theme.fg("warning", `${INCOMPLETE_WARNING_PREFIX} ${missing.join(", ")}`);
169
+ ? this.config.theme.fg("muted", t("review.ready", READY_PROMPT))
170
+ : this.config.theme.fg(
171
+ "warning",
172
+ `${t("review.incomplete", INCOMPLETE_WARNING_PREFIX)} ${missing.join(", ")}`,
173
+ );
161
174
  const out: Component[] = [new Spacer(1), new Text(promptText, 1, 0), new Spacer(1)];
162
175
  if (this.config.submitPicker) {
163
176
  out.push(this.config.submitPicker);
@@ -176,12 +189,12 @@ export class SubmitTabStrategy implements TabContentStrategy {
176
189
  * Enter · ↑/↓ [· Space toggle] [· n notes] [· Tab switch] · Esc
177
190
  */
178
191
  export function buildHintText(question: QuestionData | undefined, isMulti: boolean, state: DialogState): string {
179
- const parts: string[] = [HINT_PART_ENTER, HINT_PART_NAV];
180
- if (question?.multiSelect === true) parts.push(HINT_PART_TOGGLE);
192
+ const parts: string[] = [t("hint.enter", HINT_PART_ENTER), t("hint.navigate", HINT_PART_NAV)];
193
+ if (question?.multiSelect === true) parts.push(t("hint.toggle", HINT_PART_TOGGLE));
181
194
  if (question && question.multiSelect !== true && state.focusedOptionHasPreview && !state.notesVisible) {
182
- parts.push(HINT_PART_NOTES);
195
+ parts.push(t("hint.notes", HINT_PART_NOTES));
183
196
  }
184
- if (isMulti) parts.push(HINT_PART_TAB);
185
- parts.push(HINT_PART_CANCEL);
197
+ if (isMulti) parts.push(t("hint.tab", HINT_PART_TAB));
198
+ parts.push(t("hint.cancel", HINT_PART_CANCEL));
186
199
  return parts.join(" · ");
187
200
  }