class I18nService abstract

extends ManagedService

Abstract base class definition for a ManagedService that provides internationalization features.

To implement i18n in an application, extend this class and register an instance for the current locale before rendering the UI. Alternatively, use UIRenderContext.emitRenderChange after registering a new service to update the UI.

Note: The service name must remain "Core.I18n" (default, assigned by this base class) for internationalization features to work properly.


(name?: string): I18nService

.get() static

(): I18nService

Returns the currently registered I18n service, if any.


(): this

Register this service, making it available through properties decorated with the @service decorator until the service object is destroyed (either directly using .destroyManagedAsync(), or when another service is registered with the same name).



The name of this service, set only once by the service constructor. The preferred format for service names is Namespace.CamelCaseName.

.locale abstract


Locale identifier (e.g. en-US).



Decimal separator used by strf and bindf; defaults to ..

.loadTexts() protected

(source: string[][]): void

Load translations for use by getText; given source must be an array of tuples (i.e. arrays with 2 elements: the original key or string in the source language, and its translation).


(str: string): string

Returns a translation for given string. The string may contain formatting placeholders such as %s, these should exist in the translation as well, although their order may be changed.

If a translation is not found, the input string is returned as-is.

Note: This method is called automatically by strf and bindf, and it should not be necessary to call this method directly.


(n: number, forms: string[]): string

Pick one of the given plural forms, based on given number. Can be overridden for languages that have plural forms that are different from English and Germanic languages.

Note: This method is called automatically by strf and bindf, and it should not be necessary to call this method directly.

.format() abstract

(value: any, ...type: string[]): string

Returns a formatted string for given value, using given type specification(s) if needed, e.g. date, datetime, etc.

Note: This method is called automatically by strf, bind, and bindf. Any types supported here can be used with the |local:... binding filter and %{local:...} string format placeholder.



Inherited from ManagedObject.managedId.



Inherited from ManagedObject.managedState.

.getReferenceCount() protected

(): number

Inherited from ManagedObject.getReferenceCount.

.getManagedReferrers() protected

(): ManagedObject[]

Inherited from ManagedObject.getManagedReferrers.

.getManagedParent() protected

<TParent extends ManagedObject = ManagedObject>(ParentClass?: ManagedObjectConstructor<TParent>): TParent

Inherited from ManagedObject.getManagedParent.


<TEvent extends ManagedEvent = ManagedEvent, TConstructorArgs extends any[] = any[]>(e: string | TEvent | (new (...args: TConstructorArgs) => TEvent), ...constructorArgs: TConstructorArgs): this

Inherited from ManagedObject.emit.


(name?: string): void

Inherited from ManagedObject.emitChange.

.propagateChildEvents() protected deprecated

(...types: ((new (...args: any[]) => ManagedEvent) | ((e: ManagedEvent) => any))[]): this

Inherited from ManagedObject.propagateChildEvents.

.activateManagedAsync() protected

(): Promise<any>

Inherited from ManagedObject.activateManagedAsync.

.deactivateManagedAsync() protected

(): Promise<void>

Inherited from ManagedObject.deactivateManagedAsync.

.destroyManagedAsync() protected

(): Promise<void>

Inherited from ManagedObject.destroyManagedAsync.

.onManagedStateActivatingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateActivatingAsync.

.onManagedStateActiveAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateActiveAsync.

.onManagedStateDeactivatingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateDeactivatingAsync.

.onManagedStateInactiveAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateInactiveAsync.

.onManagedStateDestroyingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateDestroyingAsync.