This plugin adds localization (l10n) support to Transloco, enabling applications to adapt content to meet the language, cultural, and other requirements of specific locales.
Import the TranslocoLocaleModule or the specific directive/pipe you need into your standalone component.
Provide TranslocoLocaleModule in your TranslocoRootModule
import {TranslocoLocaleModule, provideTranslocoLocale } from '@jsverse/transloco-locale';
NgModule({
imports: [TranslocoLocaleModule],
providers: [
provideTranslocoLocale()
]
...
})
export class TranslocoRootModule {}
Localization Pipes
Transloco Locale provides a robust localization API through Angular pipes or services, leveraging the native JavaScript APIs.
Date Pipe
Format dates according to the locale.
<!-- Default short format -->
<span> {{ date | translocoDate }} </span>
<!-- Medium date and time -->
<span> {{ date | translocoDate: { dateStyle: 'medium', timeStyle: 'medium' } }} </span>
<!-- UTC time zone -->
<span> {{ date | translocoDate: { timeZone: 'UTC', timeStyle: 'full' } }} </span>
The plugin supports extensive configuration for both numbers and dates, which can be set globally, locally, or at the pipe level. Full documentation for these options can be found in the Intl.DateTimeFormat and Intl.NumberFormat references.