Skip to content

Sys.Language

Sys.Language holds the language the app currently uses for Labels and date formatting, and the default language used when no language is chosen. Languages are identified by the ID of their Language Business Object, for example English or German.

On the client side, the language is the End user’s choice for the app and is remembered in the browser. On the server side, it is the language of the current request: the language sent by the client, or else the best match for the browser’s Accept-Language header.

Availability: Everywhere

init(): void

Restores the language and the edit mode that the End user last chose in this browser. Lowgile calls it when the app starts; app code doesn’t need to call it.

Returns: void · Availability: Client

get language(): string;
set language(language: string);

ID of the current language.

  • On the client side, reading it returns the End user’s chosen language, or defaultLanguage if none is chosen. Setting it switches the whole app to that language and stores the choice in the browser. Client-side code may also set it to undefined to go back to the default language.
  • On the server side, it is the language of the current request. Setting it changes the language for the rest of the current request only.
Sys.Language.language = 'German'

Type: string · Availability: Everywhere

get defaultLanguage(): string;
set defaultLanguage(defaultLanguage: string);

ID of the language used when no language is chosen, and as fallback for date formatting. Default: English.

Note

On the server side, setting it changes the default language for all requests on that server, not only the current one.

Type: string · Availability: Everywhere

get languageIsoCode(): string;

ISO code of the current language, such as de-CH, as set on its Language Business Object. If the Language has no ISO code, the language ID is returned instead.

Note

On the server side, this returns the language ID (for example German), not the ISO code.

Type: string · Availability: Everywhere

get dateLocale(): globalThis.Locale;

The date-fns locale for the current language, used by Sys.Date to format dates. Lowgile picks the locale matching languageIsoCode (for de-CH, the date-fns locale deCH). If there is none, it uses the locale of defaultLanguage, and then enUS.

The returned object always reflects the language at the moment it is used, so you can keep a reference to it.

Note

Because languageIsoCode returns the language ID on the server side, server-side code usually gets the enUS locale.

Type: Locale · Availability: Everywhere

readonly defaultLanguage$: Observable<string>;

RxJS observable of defaultLanguage. It emits the current value immediately on subscription and again on each change.

Type: Observable<string> · Availability: Everywhere

readonly languageChanged$: Observable<string>;

RxJS observable that emits the language ID each time language or defaultLanguage changes. On the client side, it emits the effective language only when it actually differs from the previous one, and new subscribers get the last emitted value.

Note

On the server side, it emits an empty string instead of the language ID.

Type: Observable<string> · Availability: Everywhere

get languages(): [string, LanguageInfo][];

All languages of the app, as pairs of language ID and LanguageInfo. Use it, for example, to fill a language picker.

LanguageInfo fields

FieldTypeRequiredDescription
shortNamestringRequiredShort name of the language, for example for a compact picker.
displayNamestringRequiredName of the language as shown to End users.
isoCodestringRequiredISO code of the language, such as de-CH.
const options = Sys.Language.languages.map(([id, info]) => ({ id, label: info.displayName }))

Type: [string, LanguageInfo][] · Availability: Client

readonly effectiveLanguage: WritableSignal<string>;

Angular signal holding the effective language: the chosen language, or defaultLanguage if none is chosen. Reading it in a template or computed signal makes it update when the language changes. Change the language through language, not by setting this signal.

Type: WritableSignal<string> · Availability: Client

readonly effectiveLanguage$: Observable<string>;

RxJS observable of the effective language. New subscribers get the current value.

Type: Observable<string> · Availability: Client

get editMode(): boolean;
set editMode(editMode: boolean);

Whether translation mode is on. In translation mode, Labels are highlighted and show their texts in all languages as a tooltip, and Developers who can use the dev bar can click a Label to open it in its editor. Setting it stores the choice in the browser and makes Labels re-render.

Type: boolean · Availability: Client