Feature: localizable sandboxed plugins (manifest locales + api.i18n.t)
The plugin runtime received the active locale (init payload + 'locale-change')
and plugins could declare a `locales` map, but none of it was usable: the
locales never reached the runtime, and buildPluginApi exposed no i18n. So
plugin code calling pluginApi.i18n.t(...) (as the External Link Warning plugin
does) always got undefined and fell back to English.
Thread plugin locales end to end and surface an i18n API:
- ServerPlugin gains `locales`; the upload route persists manifest.locales
(alongside configSchema/settingsSchema), and /api/plugins surfaces it to the
client so it flows registry -> client -> sandbox host-bridge -> runtime.
- runtime sets __PLUGIN_LOCALE__ at init (not only on later 'locale-change')
and buildPluginApi exposes `i18n.locale` + `i18n.t(key, vars)` resolving
against the plugin's declared locales (manifest.locales) with English/key
fallback and {placeholder} interpolation.
Lets any sandboxed plugin localize its strings from its manifest.
This commit is contained in:
@@ -53,6 +53,13 @@ export interface ServerPlugin {
|
||||
forceEnabled?: boolean;
|
||||
configSchema?: Record<string, PluginConfigField>;
|
||||
settingsSchema?: Record<string, PluginSettingsField>;
|
||||
/**
|
||||
* Optional per-locale translation tables (locale -> key -> string) declared
|
||||
* in the plugin manifest. Surfaced to the sandbox so plugin code can call
|
||||
* `api.i18n.t(key)`; without it a plugin's strings stay in its hardcoded
|
||||
* default language.
|
||||
*/
|
||||
locales?: Record<string, Record<string, string>>;
|
||||
installedAt: string;
|
||||
updatedAt: string;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user