# SiLocaleService documentation

**Kind:** class

**Provided in:** `root`

```
import { SiLocaleService } from '@siemens/element-ng/localization';
```

```
undecorated_class SiLocaleService
```

#### Attributes and Methods

##### config

[Source for config](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L83-L89>)

**Type:** `SiLocaleConfig`

**Default:** `...`

The config for the local service.

##### hasLocale

[Source for hasLocale](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L220-L225>)

Test if the given locale is part of the available locales.

```
hasLocale(locale?: string): boolean
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [locale](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L220-L220>) (optional) | `string` |  | • The locale to be tested. |

**Returns:** [boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)

##### locale

[Source for locale](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L153-L179>)

**Type:** `string`

Sets a new locale to the locale service and also to the translate service.

Throws: An error if the new value is not configured in the available locales or if the new locale cannot be saved, an error is thrown.

##### locale$

[Source for locale$](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L68-L68>)

**Modifiers:** readonly

**Type:** `BehaviorSubject<string>`

Holds the used locale definition like en, de, or en-US.

##### localePackageLoaded$

[Source for localePackageLoaded$](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L73-L73>)

**Modifiers:** readonly

**Type:** `ReplaySubject<void>`

**Default:** `new ReplaySubject<void>(1)`

Emits to indicate that the localization package (e.g. @angular/common/locales/${localeId}) is loaded and registered. Emits after calling `localeInitializer` from the `config` object.

### Types Documentation

### [SiLocaleConfig](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L30-L61>)

**Kind:** interface

```
import type { SiLocaleConfig } from '@siemens/element-ng/localization';
```

```
interface SiLocaleConfig
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [availableLocales](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L40-L40>) (optional) | `string[]` | The list of available locales (e.g. en, fr, de, en-GB, de-AT) |
| [defaultLocale](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L36-L36>) (optional) | `string` | The default locale to be used, when no user preference available and the browser language is not part of the available languages. |
| [dynamicLanguageChange](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L60-L60>) (optional) | `boolean` | Default is false and defines that on setting a new locale, the locale is stored and the browser is reloaded. When changing to true, window reload is not invoked, but angular pure pipes like DatePipe will not work. |
| [fallbackEnabled](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L54-L54>) (optional) | `boolean` | Set to true to also enable the default language on ngx-translate. When true, ngx-translate will use a translate value from the default language when a required value is not available in the current language. But note, this will also enforce to load the default language translation file into the application, even if a different locale is active. In other words, the application start time increases. |
| [localeInitializer](<https://github.com/siemens/element/blob/main/projects/element-ng/localization/si-locale.service.ts#L46-L46>) (optional) | `((localeId: string) => Promise<any>)` | The localeInitializer function is invoked on every locale change. Make sure to invoke `registerLocaleData` with the locale to enable the Angular localization. |
