@punica/editor 1.7.1 → 1.8.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/dist/index.bundle.esm.js +2 -2
- package/dist/index.bundle.esm.js.map +1 -1
- package/dist/index.bundle.umd.js +2 -2
- package/dist/index.bundle.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/punica.module.extensions.api.d.ts +23 -0
- package/types/punica.module.extensions.i18n.d.ts +83 -0
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
/// <reference path="punica.module.kernel.tasks.d.ts" />
|
|
24
24
|
/// <reference path="punica.module.extensions.api.d.ts" />
|
|
25
25
|
/// <reference path="punica.module.extensions.settings.d.ts" />
|
|
26
|
+
/// <reference path="punica.module.extensions.i18n.d.ts" />
|
|
26
27
|
/// <reference path="punica.module.runtime.fs.d.ts" />
|
|
27
28
|
/// <reference path="punica.module.runtime.search.d.ts" />
|
|
28
29
|
/// <reference path="punica.module.runtime.vcs.d.ts" />
|
|
@@ -716,6 +716,16 @@ declare module 'punica' {
|
|
|
716
716
|
*/
|
|
717
717
|
export const manager: extensions.settings.SettingsApi;
|
|
718
718
|
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Localization engine for extension user interfaces.
|
|
722
|
+
*/
|
|
723
|
+
namespace i18n {
|
|
724
|
+
/**
|
|
725
|
+
* Localization façade surfaced via `punica.extensions.i18n.manager`.
|
|
726
|
+
*/
|
|
727
|
+
export const manager: extensions.i18n.I18nApi;
|
|
728
|
+
}
|
|
719
729
|
}
|
|
720
730
|
|
|
721
731
|
/**
|
|
@@ -809,5 +819,18 @@ declare module 'punica' {
|
|
|
809
819
|
*/
|
|
810
820
|
export const manager: SettingsApi;
|
|
811
821
|
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Localization engine — see punica.module.extensions.i18n.d.ts.
|
|
825
|
+
*/
|
|
826
|
+
export namespace i18n {
|
|
827
|
+
export import I18nApi = extensions.i18n.I18nApi;
|
|
828
|
+
export import MessageBundle = extensions.i18n.MessageBundle;
|
|
829
|
+
export import MessageBundles = extensions.i18n.MessageBundles;
|
|
830
|
+
/**
|
|
831
|
+
* Localization façade surfaced via `punica.extensions.i18n.manager`.
|
|
832
|
+
*/
|
|
833
|
+
export const manager: I18nApi;
|
|
834
|
+
}
|
|
812
835
|
}
|
|
813
836
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace extensions {
|
|
3
|
+
/**
|
|
4
|
+
* Localization for extension user interfaces.
|
|
5
|
+
*
|
|
6
|
+
* The substrate owns the ENGINE — one active locale, one change event, one
|
|
7
|
+
* plural implementation — and extensions own only their dictionaries. The
|
|
8
|
+
* alternative, a helper copied into every extension, is how this fleet
|
|
9
|
+
* handles small utilities, but an engine is not a small utility: 80-odd
|
|
10
|
+
* copies of plural selection and fallback order drift apart, and the drift
|
|
11
|
+
* shows up as a half-translated screen rather than a failing build.
|
|
12
|
+
*
|
|
13
|
+
* The language is stored in the shared `system` / `ui.language` setting,
|
|
14
|
+
* the same namespace the theme lives in, so every extension resolves the
|
|
15
|
+
* same value. The set of offered languages comes from the active
|
|
16
|
+
* ApplicationProfile's `localization.supported` — a v1 slot that existed
|
|
17
|
+
* unused until this API filled it.
|
|
18
|
+
*/
|
|
19
|
+
export namespace i18n {
|
|
20
|
+
/** A dictionary: flat dot-separated keys to display strings. */
|
|
21
|
+
export type MessageBundle = Record<string, string>;
|
|
22
|
+
|
|
23
|
+
/** Locale tag (`en`, `tr`) to that locale's dictionary. */
|
|
24
|
+
export type MessageBundles = Record<string, MessageBundle>;
|
|
25
|
+
|
|
26
|
+
export interface I18nApi {
|
|
27
|
+
/**
|
|
28
|
+
* The active locale tag. Resolution order: the `ui.language` setting,
|
|
29
|
+
* then the app/OS language's subtag when it is supported, then the
|
|
30
|
+
* profile's declared default, then `'en'`.
|
|
31
|
+
*/
|
|
32
|
+
getLocale(): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Change the language for the whole application. Writes
|
|
36
|
+
* `system` / `ui.language` at global scope and notifies subscribers;
|
|
37
|
+
* callers do not write the setting themselves.
|
|
38
|
+
*/
|
|
39
|
+
setLocale(locale: string): Promise<void>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Languages this product offers, from the active profile's
|
|
43
|
+
* `localization.supported`. Falls back to `['en']` when the profile
|
|
44
|
+
* declares none.
|
|
45
|
+
*/
|
|
46
|
+
supportedLocales(): string[];
|
|
47
|
+
|
|
48
|
+
/** Subscribe to language changes. Returns an unsubscribe function. */
|
|
49
|
+
onDidChange(listener: (locale: string) => void): () => void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Register an extension's dictionaries, keyed by locale tag. Call once
|
|
53
|
+
* during `activate()`, before anything renders. Registering again for
|
|
54
|
+
* the same extension replaces the previous bundles, so a reload during
|
|
55
|
+
* development does not accumulate stale strings.
|
|
56
|
+
*/
|
|
57
|
+
register(extensionName: string, bundles: MessageBundles): void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Look up a message for a registered extension.
|
|
61
|
+
*
|
|
62
|
+
* `params` values are interpolated into `{name}` placeholders. A
|
|
63
|
+
* numeric `params.count` also selects a plural form: the lookup tries
|
|
64
|
+
* `<key>.<pluralCategory>` (via `Intl.PluralRules`) before `<key>`,
|
|
65
|
+
* which is what lets English say "1 attempt" / "2 attempts" while
|
|
66
|
+
* Turkish keeps one form after a numeral.
|
|
67
|
+
*
|
|
68
|
+
* Never throws. When no message is found — unregistered extension,
|
|
69
|
+
* unknown key, missing locale — the key itself is returned, because a
|
|
70
|
+
* visible key is greppable and cannot be mistaken for finished copy.
|
|
71
|
+
*/
|
|
72
|
+
t(
|
|
73
|
+
extensionName: string,
|
|
74
|
+
key: string,
|
|
75
|
+
params?: Record<string, string | number>
|
|
76
|
+
): string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Localization façade surfaced via `punica.extensions.i18n.manager`. */
|
|
80
|
+
export const manager: I18nApi;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|