# WR_LIVE_LOCALE

> The interface language as a signal, for code that follows a language switch without importing `ngwr/i18n`.

Source: https://ngwr.dev/reference/utils/wr-live-locale  
Kind: Util  
Added in v16.1  
Optional

## Usage

`provideWrI18n()` provides it as `WrI18n.locale`. An app without i18n does not provide it, so inject it as optional and fall back to `LOCALE_ID`.

```angular-ts
import { LOCALE_ID, computed, inject } from '@angular/core';
import { WR_LIVE_LOCALE } from 'ngwr/utils';

private readonly live = inject(WR_LIVE_LOCALE, { optional: true });
private readonly fallback = inject(LOCALE_ID);

// Rewritten when the app calls WrI18n.use().
protected readonly price = computed(() =>
  new Intl.NumberFormat(this.live?.() ?? this.fallback, { style: 'currency', currency: 'EUR' }).format(this.amount())
);
```

| You want | Read |
| --- | --- |
| The language, in an app that has i18n | `inject(WrI18n).locale` |
| The language, in a library that must not import `ngwr/i18n` | `WR_LIVE_LOCALE` |
| The locale dates are written in | `wrDateLocale()` from `ngwr/date`, which also honours a pinned locale |

- The value is the code the app passes to `WrI18n.use()`. `Intl` throws on a code that is not a BCP 47 tag, so guard it when the app names its languages another way.

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `WR_LIVE_LOCALE` | The interface language of `provideWrI18n()`, the signal `WrI18n.locale`. Not provided without `provideWrI18n()`. | `InjectionToken<Signal<string>>` | `-` |

## See also

- [WrI18n](https://ngwr.dev/reference/services/i18n) — Translate strings at runtime and switch the locale without a reload.
- [Setup & loaders](https://ngwr.dev/guides/translations/setup) — Provide WrI18n and load your catalogs.
- [Configuration](https://ngwr.dev/docs/configuration) — Set app-wide options at bootstrap.
- [wrDate](https://ngwr.dev/reference/pipes/wr-date) — Format a date with a named preset or a token string.
