@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.
constructor SheetI18nLocaleRegistry(): SheetI18nLocaleRegistryproperty readonly symbol: typeof symbolstaticDI token for resolving SheetI18nLocaleRegistry.
method enforceCommandBoundary(isExecuting: (): boolean, dispatchRemoval: (id: number): void): voidSeals runtime registrations after every plugin has started.
method get(locale: string): SheetI18nLocaleEntry | undefinedReturns a registered locale contribution, if present.
method has(locale: string): booleanReturns whether a locale id is registered.
method list(): readonly SheetI18nLocaleEntry[]Lists registered locale contributions in stable locale-id order.
method register(registration: SheetI18nLocaleRegistration): (): voidRegisters one locale contribution and returns an idempotent disposer.
method require(locale: string): SheetI18nLocaleEntryReturns a required locale contribution.
method unregister(id: number): voidRemoves one contribution through the locale owner's command after assembly.
- interfaceSheetI18nLocaleEntry
-
Normalized locale contribution stored by the editor-local registry.
property readonly cellFormatLocale: CellFormatLocaleSheet cell number and date/time display defaults for this locale.
property readonly dateTimeLocale: FormulaDateTimeLocaleFormula date/time parser and formatter for this locale.
property readonly dateTimeSymbols?: FormulaDateTimeSymbolsLocale-specific date/time symbols used by the shared Excel parser.
property readonly displayName: stringUser-facing language label supplied by the owner.
property readonly locale: stringStable locale id, normally a BCP-47 tag such as en, zh-CN, ja-JP, or fr-FR.
property readonly textLocale: FormulaTextLocaleFormula text byte/width strategy for DBCS-compatible functions.
- interfaceSheetI18nLocaleRegistration
-
Locale contribution registered with the editor-local i18n registry.
property readonly cellFormatLocale?: CellFormatLocaleSheet cell number and date/time display defaults for this locale.
property readonly dateTimeLocale?: FormulaDateTimeLocaleFormula date/time parser and formatter for this locale.
property readonly dateTimeSymbols?: FormulaDateTimeSymbolsLocale-specific date/time symbols used by the shared Excel parser.
property readonly displayName: stringUser-facing language label supplied by the owner.
property readonly locale: stringStable locale id, normally a BCP-47 tag such as en, zh-CN, ja-JP, or fr-FR.
property readonly textLocale?: FormulaTextLocaleFormula 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): valueReturns whether a value is a non-empty locale id.
- functionregisterBuiltInSheetI18nLocales
-
registerBuiltInSheetI18nLocales(registry: SheetI18nLocaleRegistry): voidRegisters the default English and Chinese locale contributions.
Change the editor locale
- classSheetI18nPlugin
-
class SheetI18nPlugin extends Plugin<SearCoreSheet, CellProperties, null>, IFormulaLocaleProvider, ICellFormatLocaleProviderEditor-local i18n plugin for built-in English and Chinese locale services.
constructor SheetI18nPlugin(locales: SheetI18nLocaleRegistry): SheetI18nPluginproperty readonly pluginKey: PluginKeystaticStable plugin key for SheetI18nPlugin.
property readonly symbol: typeof symbolstaticDI token for resolving SheetI18nPlugin.
method apply(state: null, _transaction: Transaction): nullApplies no document mutations because i18n is local runtime state.
method getCellFormatLocale(): CellFormatLocaleICellFormatLocaleProvider implementation.
method getDateTimeLocale(): FormulaDateTimeLocaleIFormulaLocaleProvider implementation.
method getLocale(): stringReturns the active locale.
method getPluginConfig(): nullReturns the plugin config.
method getTextLocale(): FormulaTextLocaleIFormulaLocaleProvider implementation.
method initialize(context: { container: Container }): voidDiscovers formula scheduling after the formula runtime has registered its services.
method registerCapabilities(registry: RuntimeCapabilityRegistry): voidPublishes the i18n locale registry for third-party locale contributions.
method registerCommands(commands: SheetCommandBus): voidRegisters language switching commands.
method registerObservations(observations: ObservationRegistry): voidRegisters the current i18n state observation.
method registerSessionState(registry: SessionStateRegistry): voidRegisters local i18n state for in-memory editor remounts.
method registerState(): { dataEngine: { enabled: boolean }; key: PluginKey; state: null }Registers private plugin state.
method render(): Node<CellProperties>[]This plugin renders no scene nodes.
method sealRuntimeWrites(): voidCloses runtime-owned extension writes after every plugin has initialized and started.
method setLocale(locale: string): voidUpdates the active locale and notifies observers.
method toggleLocale(): voidToggles between English and Chinese.
method registerServices(context: { container: Container }): voidstaticPublishes this plugin as the editor-local formula locale provider.
Inherited members 28
Inherited from Plugin.
- depth
- documentState
- interestedIn
- transactionHistory
- transactionOT
- warnOnDuplicateDepth
- key
- dirtyRect
- enforceRuntimeWriteBoundary
- enforceStateWriteBoundary
- getState
- hasStateWriteBoundary
- lockCommittedState
- onClick
- onDblClick
- onInitialDataCell
- onInitialDataComplete
- onMouseDown
- onMouseMove
- onMouseUp
- onResize
- onScroll
- onTransactionCommitted
- projectTransaction
- registerConfig
- sealRuntimeMetadata
- sealRuntimeMethods
- setState
- interfaceSetSheetLocaleInput
-
Input for setting the editor-local language.
property readonly locale: string - interfaceSheetI18nState
-
Snapshot published by the sheet i18n observation.
property readonly locale: string - typeSheetI18nLocale
-
type SheetI18nLocale = stringLocale 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.
No matching API entries.