@hoardodile/i18n 0.0.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.
Files changed (50) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +81 -0
  3. package/dist/catalogs/ui.d.ts +2 -0
  4. package/dist/catalogs/ui.js +449 -0
  5. package/dist/catalogs/ui.js.map +1 -0
  6. package/dist/catalogs/workbench.d.ts +291 -0
  7. package/dist/catalogs/workbench.js +250 -0
  8. package/dist/catalogs/workbench.js.map +1 -0
  9. package/dist/catalogs-BF4px4Mm.d.ts +12986 -0
  10. package/dist/catalogs.d.ts +2 -0
  11. package/dist/catalogs.js +10794 -0
  12. package/dist/catalogs.js.map +1 -0
  13. package/dist/core.d.ts +32 -0
  14. package/dist/core.js +14 -0
  15. package/dist/core.js.map +1 -0
  16. package/dist/create-i18n.d.ts +35 -0
  17. package/dist/create-i18n.js +30 -0
  18. package/dist/create-i18n.js.map +1 -0
  19. package/dist/index.d.ts +42 -0
  20. package/dist/index.js +11284 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/react.d.ts +1 -0
  23. package/dist/react.js +3 -0
  24. package/dist/react.js.map +1 -0
  25. package/dist/ui-CJPMCZT7.d.ts +548 -0
  26. package/package.json +81 -0
  27. package/src/catalogs/de.json +2155 -0
  28. package/src/catalogs/en.json +2155 -0
  29. package/src/catalogs/es.json +2155 -0
  30. package/src/catalogs/ja.json +2155 -0
  31. package/src/catalogs/ui.ts +30 -0
  32. package/src/catalogs/workbench.ts +29 -0
  33. package/src/catalogs/zh.json +2155 -0
  34. package/src/catalogs.ts +31 -0
  35. package/src/core.ts +40 -0
  36. package/src/create-i18n.ts +52 -0
  37. package/src/index.ts +66 -0
  38. package/src/language.test.ts +70 -0
  39. package/src/parity.test.ts +175 -0
  40. package/src/react.ts +25 -0
  41. package/src/ui/de.json +86 -0
  42. package/src/ui/en.json +86 -0
  43. package/src/ui/es.json +86 -0
  44. package/src/ui/ja.json +86 -0
  45. package/src/ui/zh.json +86 -0
  46. package/src/workbench/de.json +45 -0
  47. package/src/workbench/en.json +45 -0
  48. package/src/workbench/es.json +45 -0
  49. package/src/workbench/ja.json +45 -0
  50. package/src/workbench/zh.json +45 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The `ui` catalog registry: component-chrome strings shared by every
3
+ * React consumer — `@hoardodile/ui` components (`useTranslation("ui")`),
4
+ * the host surfaces and the plugin SDK iframes. Like the app catalogs
5
+ * these five JSON modules must stay in lockstep; `parity.test.ts`
6
+ * enforces it and `Record<SupportedLanguage, typeof en>` makes key drift
7
+ * a compile error.
8
+ *
9
+ * Console: `catalogFor` in `./catalogs.ts` serves the app `translation`
10
+ * namespace; `uiCatalogFor` here serves the `ui` namespace.
11
+ */
12
+
13
+ import type { SupportedLanguage } from "../core.ts"
14
+ import de from "../ui/de.json"
15
+ import en from "../ui/en.json"
16
+ import es from "../ui/es.json"
17
+ import ja from "../ui/ja.json"
18
+ import zh from "../ui/zh.json"
19
+
20
+ export const UI_CATALOGS = { en, zh, ja, de, es } as const satisfies Record<
21
+ SupportedLanguage,
22
+ typeof en
23
+ >
24
+
25
+ /** Resolve the ui catalog for the active language; undefined → English. */
26
+ export function uiCatalogFor(
27
+ language: SupportedLanguage | undefined,
28
+ ): typeof en {
29
+ return language === undefined ? en : UI_CATALOGS[language]
30
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The workbench catalog registry: dev-tool chrome strings (the offline
3
+ * plugin workbench's own UI — toolbar, config popover, empty states).
4
+ * Unlike the `ui` namespace these are never bundled by the app or the
5
+ * plugin SDK; only the workbench imports this subpath. Same lockstep
6
+ * rules as the other catalogs; `parity.test.ts` enforces them.
7
+ */
8
+
9
+ import type { SupportedLanguage } from "../core.ts"
10
+ import de from "../workbench/de.json"
11
+ import en from "../workbench/en.json"
12
+ import es from "../workbench/es.json"
13
+ import ja from "../workbench/ja.json"
14
+ import zh from "../workbench/zh.json"
15
+
16
+ export const WORKBENCH_CATALOGS = {
17
+ en,
18
+ zh,
19
+ ja,
20
+ de,
21
+ es,
22
+ } as const satisfies Record<SupportedLanguage, typeof en>
23
+
24
+ /** Resolve the workbench catalog for the active language; undefined → English. */
25
+ export function workbenchCatalogFor(
26
+ language: SupportedLanguage | undefined,
27
+ ): typeof en {
28
+ return language === undefined ? en : WORKBENCH_CATALOGS[language]
29
+ }