← All packages

API reference

@searsuite/sear-plugin-i18n

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

16 exportsderived from source

classSheetI18nLocaleRegistrysource ↗
class SheetI18nLocaleRegistry

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

constructorconstructor
SheetI18nLocaleRegistry(): SheetI18nLocaleRegistry
propertysymbolstatic
readonly symbol: typeof symbol

DI token for resolving SheetI18nLocaleRegistry.

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

Seals runtime registrations after every plugin has started.

isExecuting: (): boolean
dispatchRemoval: (id: number): void
methodget
get(locale: string): SheetI18nLocaleEntry | undefined

Returns a registered locale contribution, if present.

locale: string
methodhas
has(locale: string): boolean

Returns whether a locale id is registered.

locale: string
methodlist
list(): readonly SheetI18nLocaleEntry[]

Lists registered locale contributions in stable locale-id order.

methodregister
register(registration: SheetI18nLocaleRegistration): (): void

Registers one locale contribution and returns an idempotent disposer.

registration: SheetI18nLocaleRegistration
methodrequire
require(locale: string): SheetI18nLocaleEntry

Returns a required locale contribution.

locale: string
methodunregister
unregister(id: number): void

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

id: number
classSheetI18nPluginsource ↗
class SheetI18nPlugin extends Plugin<SearCoreSheet, CellProperties, null>, IFormulaLocaleProvider, ICellFormatLocaleProvider

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

constructorconstructor
SheetI18nPlugin(locales: SheetI18nLocaleRegistry): SheetI18nPlugin

Creates a SheetI18nPlugin instance.

locales: SheetI18nLocaleRegistry
propertypluginKeystatic
readonly pluginKey: PluginKey

Stable plugin key for SheetI18nPlugin.

propertysymbolstatic
readonly symbol: typeof symbol

DI token for resolving SheetI18nPlugin.

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

Applies no document mutations because i18n is local runtime state.

state: null
_transaction: Transaction
methodgetCellFormatLocale
getCellFormatLocale(): CellFormatLocale

ICellFormatLocaleProvider implementation.

methodgetDateTimeLocale
getDateTimeLocale(): FormulaDateTimeLocale

IFormulaLocaleProvider implementation.

methodgetLocale
getLocale(): string

Returns the active locale.

methodgetPluginConfig
getPluginConfig(): null

Returns the plugin config.

methodgetTextLocale
getTextLocale(): FormulaTextLocale

IFormulaLocaleProvider implementation.

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

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

context: { container: Container }
methodregisterCapabilities
registerCapabilities(registry: RuntimeCapabilityRegistry): void

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

registry: RuntimeCapabilityRegistry
methodregisterCommands
registerCommands(commands: SheetCommandBus): void

Registers language switching commands.

commands: SheetCommandBus
methodregisterObservations
registerObservations(observations: ObservationRegistry): void

Registers the current i18n state observation.

observations: ObservationRegistry
methodregisterSessionState
registerSessionState(registry: SessionStateRegistry): void

Registers local i18n state for in-memory editor remounts.

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

Registers private plugin state.

methodrender
render(): Node<CellProperties>[]

This plugin renders no scene nodes.

methodsealRuntimeWrites
sealRuntimeWrites(): void

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

methodsetLocale
setLocale(locale: string): void

Updates the active locale and notifies observers.

locale: string
methodtoggleLocale
toggleLocale(): void

Toggles between English and Chinese.

methodregisterServicesstatic
registerServices(context: { container: Container }): void

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

context: { container: Container }
Inherited members 29

Inherited from Plugin.

interfaceSetSheetLocaleInputsource ↗
interface SetSheetLocaleInput

Input for setting the editor-local language.

propertylocale
readonly locale: string
interfaceSheetI18nLocaleEntrysource ↗
interface SheetI18nLocaleEntry

Normalized locale contribution stored by the editor-local registry.

propertycellFormatLocale
readonly cellFormatLocale: CellFormatLocale

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

propertydateTimeLocale
readonly dateTimeLocale: FormulaDateTimeLocale

Formula date/time parser and formatter for this locale.

propertydateTimeSymbols
readonly dateTimeSymbols?: FormulaDateTimeSymbols

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

propertydisplayName
readonly displayName: string

User-facing language label supplied by the owner.

propertylocale
readonly locale: string

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

propertytextLocale
readonly textLocale: FormulaTextLocale

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

interfaceSheetI18nLocaleRegistrationsource ↗
interface SheetI18nLocaleRegistration

Locale contribution registered with the editor-local i18n registry.

propertycellFormatLocale
readonly cellFormatLocale?: CellFormatLocale

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

propertydateTimeLocale
readonly dateTimeLocale?: FormulaDateTimeLocale

Formula date/time parser and formatter for this locale.

propertydateTimeSymbols
readonly dateTimeSymbols?: FormulaDateTimeSymbols

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

propertydisplayName
readonly displayName: string

User-facing language label supplied by the owner.

propertylocale
readonly locale: string

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

propertytextLocale
readonly textLocale?: FormulaTextLocale

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

interfaceSheetI18nStatesource ↗
interface SheetI18nState

Snapshot published by the sheet i18n observation.

propertylocale
readonly locale: string
typeSheetI18nLocalesource ↗
type SheetI18nLocale = string

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

variableSetSheetLocaleCommandsource ↗
SetSheetLocaleCommand: SheetCommandDefinition<SetSheetLocaleInput, SheetCommandResult>

Command that updates the editor-local language.

variableSheetI18nBuiltInLocalesource ↗
SheetI18nBuiltInLocale: { Chinese: "zh"; English: "en" }

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

variableSheetI18nLocaleRegistryCapabilitysource ↗
SheetI18nLocaleRegistryCapability: RuntimeCapability<SheetI18nLocaleRegistry>

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

variableSheetI18nSessionStateDefinitionsource ↗
SheetI18nSessionStateDefinition: SessionStateDefinition<SheetI18nState>

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

variableSheetI18nStateObservationsource ↗
SheetI18nStateObservation: StateObservationDefinition<SheetI18nState>

Editor-local sheet i18n locale state.

variableToggleSheetLocaleCommandsource ↗
ToggleSheetLocaleCommand: SheetCommandDefinition<void, SheetCommandResult>

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

variableUnregisterSheetI18nLocaleCommandsource ↗
UnregisterSheetI18nLocaleCommand: SheetCommandDefinition<number, SheetCommandResult>

Removes one editor-local locale contribution.

functionisSheetI18nLocalesource ↗
isSheetI18nLocale(value: unknown): value

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

value: unknown
functionregisterBuiltInSheetI18nLocalessource ↗
registerBuiltInSheetI18nLocales(registry: SheetI18nLocaleRegistry): void

Registers the default English and Chinese locale contributions.

registry: SheetI18nLocaleRegistry