← All packages

@searsuite/sear-plugin-i18n

Editor-local locale registration and built-in English and Chinese formula locales.

Register locales

classSheetI18nLocaleRegistry

Editor-local registry for built-in and third-party locale contributions.

constructorSheetI18nLocaleRegistry(): SheetI18nLocaleRegistry
propertyreadonly symbol: typeof symbolstatic

DI token for resolving SheetI18nLocaleRegistry.

methodenforceCommandBoundary(isExecuting: (): boolean, dispatchRemoval: (id: number): void): void

Seals runtime registrations after every plugin has started.

methodget(locale: string): SheetI18nLocaleEntry | undefined

Returns a registered locale contribution, if present.

methodhas(locale: string): boolean

Returns whether a locale id is registered.

methodlist(): readonly SheetI18nLocaleEntry[]

Lists registered locale contributions in stable locale-id order.

methodregister(registration: SheetI18nLocaleRegistration): (): void

Registers one locale contribution and returns an idempotent disposer.

methodrequire(locale: string): SheetI18nLocaleEntry

Returns a required locale contribution.

methodunregister(id: number): void

Removes one contribution through the locale owner's command after assembly.

interfaceSheetI18nLocaleEntry

Normalized locale contribution stored by the editor-local registry.

propertyreadonly cellFormatLocale: CellFormatLocale

Sheet cell number and date/time display defaults for this locale.

propertyreadonly dateTimeLocale: FormulaDateTimeLocale

Formula date/time parser and formatter for this locale.

propertyreadonly dateTimeSymbols?: FormulaDateTimeSymbols

Locale-specific date/time symbols used by the shared Excel parser.

propertyreadonly displayName: string

User-facing language label supplied by the owner.

propertyreadonly locale: string

Stable locale id, normally a BCP-47 tag such as en, zh-CN, ja-JP, or fr-FR.

propertyreadonly textLocale: FormulaTextLocale

Formula text byte/width strategy for DBCS-compatible functions.

interfaceSheetI18nLocaleRegistration

Locale contribution registered with the editor-local i18n registry.

propertyreadonly cellFormatLocale?: CellFormatLocale

Sheet cell number and date/time display defaults for this locale.

propertyreadonly dateTimeLocale?: FormulaDateTimeLocale

Formula date/time parser and formatter for this locale.

propertyreadonly dateTimeSymbols?: FormulaDateTimeSymbols

Locale-specific date/time symbols used by the shared Excel parser.

propertyreadonly displayName: string

User-facing language label supplied by the owner.

propertyreadonly locale: string

Stable locale id, normally a BCP-47 tag such as en, zh-CN, ja-JP, or fr-FR.

propertyreadonly textLocale?: FormulaTextLocale

Formula text byte/width strategy for DBCS-compatible functions.

variableSheetI18nBuiltInLocale
SheetI18nBuiltInLocale: { Chinese: "zh"; English: "en" }

Built-in locale identifiers registered by sear-plugin-i18n.

variableSheetI18nLocaleRegistryCapability
SheetI18nLocaleRegistryCapability: RuntimeCapability<SheetI18nLocaleRegistry>

Runtime capability that exposes the sheet i18n locale registry to plugins and hosts.

functionisSheetI18nLocale
isSheetI18nLocale(value: unknown): value

Returns whether a value is a non-empty locale id.

functionregisterBuiltInSheetI18nLocales
registerBuiltInSheetI18nLocales(registry: SheetI18nLocaleRegistry): void

Registers the default English and Chinese locale contributions.

Change the editor locale

classSheetI18nPlugin
class SheetI18nPlugin extends Plugin<SearCoreSheet, CellProperties, null>, IFormulaLocaleProvider, ICellFormatLocaleProvider

Editor-local i18n plugin for built-in English and Chinese locale services.

constructorSheetI18nPlugin(locales: SheetI18nLocaleRegistry): SheetI18nPlugin
propertyreadonly pluginKey: PluginKeystatic

Stable plugin key for SheetI18nPlugin.

propertyreadonly symbol: typeof symbolstatic

DI token for resolving SheetI18nPlugin.

methodapply(state: null, _transaction: Transaction): null

Applies no document mutations because i18n is local runtime state.

methodgetCellFormatLocale(): CellFormatLocale

ICellFormatLocaleProvider implementation.

methodgetDateTimeLocale(): FormulaDateTimeLocale

IFormulaLocaleProvider implementation.

methodgetLocale(): string

Returns the active locale.

methodgetPluginConfig(): null

Returns the plugin config.

methodgetTextLocale(): FormulaTextLocale

IFormulaLocaleProvider implementation.

methodinitialize(context: { container: Container }): void

Discovers formula scheduling after the formula runtime has registered its services.

methodregisterCapabilities(registry: RuntimeCapabilityRegistry): void

Publishes the i18n locale registry for third-party locale contributions.

methodregisterCommands(commands: SheetCommandBus): void

Registers language switching commands.

methodregisterObservations(observations: ObservationRegistry): void

Registers the current i18n state observation.

methodregisterSessionState(registry: SessionStateRegistry): void

Registers local i18n state for in-memory editor remounts.

methodregisterState(): { dataEngine: { enabled: boolean }; key: PluginKey; state: null }

Registers private plugin state.

methodrender(): Node<CellProperties>[]

This plugin renders no scene nodes.

methodsealRuntimeWrites(): void

Closes runtime-owned extension writes after every plugin has initialized and started.

methodsetLocale(locale: string): void

Updates the active locale and notifies observers.

methodtoggleLocale(): void

Toggles between English and Chinese.

methodregisterServices(context: { container: Container }): voidstatic

Publishes this plugin as the editor-local formula locale provider.

Inherited members 28

Inherited from Plugin.

interfaceSetSheetLocaleInput

Input for setting the editor-local language.

interfaceSheetI18nState

Snapshot published by the sheet i18n observation.

typeSheetI18nLocale
type SheetI18nLocale = string

Locale ids are open so third-party plugins can register their own BCP-47 tags.

variableSetSheetLocaleCommand
SetSheetLocaleCommand: SheetCommandDefinition<SetSheetLocaleInput, SheetCommandResult>

Command that updates the editor-local language.

variableSheetI18nSessionStateDefinition
SheetI18nSessionStateDefinition: SessionStateDefinition<SheetI18nState>

Local sheet i18n locale retained during in-memory editor remounts.

variableSheetI18nStateObservation
SheetI18nStateObservation: StateObservationDefinition<SheetI18nState>

Editor-local sheet i18n locale state.

variableToggleSheetLocaleCommand
ToggleSheetLocaleCommand: SheetCommandDefinition<void, SheetCommandResult>

Command that toggles between the built-in English and Chinese locales.

variableUnregisterSheetI18nLocaleCommand
UnregisterSheetI18nLocaleCommand: SheetCommandDefinition<number, SheetCommandResult>

Removes one editor-local locale contribution.