@juicesharp/rpiv-voice 1.9.1 → 1.9.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/index.ts +11 -35
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to `@juicesharp/rpiv-voice` are documented here.
5
5
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
  Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.9.2] - 2026-05-19
9
+
10
+ ### Changed
11
+ - Adding a translated locale no longer requires editing the extension entry — drop `locales/<code>.json` next to the existing files and it loads automatically on next start.
12
+
8
13
  ## [1.9.1] - 2026-05-19
9
14
 
10
15
  ## [1.9.0] - 2026-05-18
package/index.ts CHANGED
@@ -10,53 +10,29 @@
10
10
  * every call site. The extension stays online either way.
11
11
  *
12
12
  * Adding a locale: drop `locales/<code>.json` next to en.json (mirroring
13
- * the key set), then add the load + entry to the `registerStrings` call
14
- * below. See `@juicesharp/rpiv-i18n` README → "Contributing translations"
15
- * for the full convention.
13
+ * the key set). No edit needed here `registerLocalesFromDir` iterates
14
+ * `SUPPORTED_LOCALES` from the SDK. See `@juicesharp/rpiv-i18n` README →
15
+ * "Contributing translations" for the full convention.
16
16
  */
17
17
 
18
- import { readFileSync } from "node:fs";
19
- import { fileURLToPath } from "node:url";
20
18
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
21
19
  import { registerVoiceCommand } from "./command/voice-command.js";
22
20
  import { I18N_NAMESPACE } from "./state/i18n-bridge.js";
23
21
 
24
- type TranslationMap = Readonly<Record<string, string>>;
25
- type I18nSDK = { registerStrings: (namespace: string, byLocale: Record<string, TranslationMap>) => void };
26
-
27
- function loadLocale(code: string): TranslationMap {
28
- // A missing or malformed locale file degrades gracefully: registerStrings
29
- // records an empty map for the locale, so render-time `t(key, fallback)`
30
- // returns the canonical English literal at the call site. Crashing here
31
- // would take the entire /voice command offline at module init.
32
- try {
33
- return JSON.parse(
34
- readFileSync(fileURLToPath(new URL(`./locales/${code}.json`, import.meta.url)), "utf-8"),
35
- ) as TranslationMap;
36
- } catch (err) {
37
- console.warn(
38
- `rpiv-voice: failed to load locales/${code}.json — falling back to English (${(err as Error).message})`,
39
- );
40
- return {};
41
- }
42
- }
22
+ type I18nLoader = {
23
+ registerLocalesFromDir: (namespace: string, packageUrl: string, options?: { label?: string }) => void;
24
+ };
43
25
 
44
26
  // Dynamic import keeps `@juicesharp/rpiv-i18n` a soft optional peer: when the
45
27
  // SDK is installed alongside this package the strings register and
46
28
  // `/languages` flips them live; when it isn't, the import rejects here, we
47
29
  // no-op, and the bridge's English-fallback shim keeps the extension online.
30
+ //
31
+ // The `/loader` subpath is used instead of the SDK entry so the i18n-ui +
32
+ // pi-tui modules are not pulled into our load graph just to register strings.
48
33
  try {
49
- const sdk = (await import("@juicesharp/rpiv-i18n")) as I18nSDK;
50
- sdk.registerStrings(I18N_NAMESPACE, {
51
- de: loadLocale("de"),
52
- en: loadLocale("en"),
53
- es: loadLocale("es"),
54
- fr: loadLocale("fr"),
55
- pt: loadLocale("pt"),
56
- "pt-BR": loadLocale("pt-BR"),
57
- ru: loadLocale("ru"),
58
- uk: loadLocale("uk"),
59
- });
34
+ const sdk = (await import("@juicesharp/rpiv-i18n/loader")) as I18nLoader;
35
+ sdk.registerLocalesFromDir(I18N_NAMESPACE, import.meta.url, { label: "rpiv-voice" });
60
36
  } catch {
61
37
  // SDK absent — extension still loads with English-only UI.
62
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-voice",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "private": false,
5
5
  "description": "Pi extension. Voice dictation via /voice — local on-device STT with sherpa-onnx Whisper (base multilingual int8), microphone capture via decibri.",
6
6
  "keywords": [
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  },
80
80
  "dependencies": {
81
- "@juicesharp/rpiv-config": "^1.9.1",
81
+ "@juicesharp/rpiv-config": "^1.9.2",
82
82
  "sherpa-onnx-node": "^1.13.0",
83
83
  "decibri": "^3.4.0"
84
84
  },