<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DatePipe &#8211; Pauls Blog</title>
	<atom:link href="https://sterl.org/tag/datepipe/feed/" rel="self" type="application/rss+xml" />
	<link>https://sterl.org</link>
	<description></description>
	<lastBuildDate>Sat, 21 Jan 2023 12:54:35 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Angular configure user browser locale</title>
		<link>https://sterl.org/2023/01/angular-configure-user-browser-locale/</link>
					<comments>https://sterl.org/2023/01/angular-configure-user-browser-locale/#respond</comments>
		
		<dc:creator><![CDATA[Paul Sterl]]></dc:creator>
		<pubDate>Sat, 21 Jan 2023 12:54:35 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[date pipe]]></category>
		<category><![CDATA[DatePipe]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[LOCALE_ID]]></category>
		<guid isPermaLink="false">https://sterl.org/?p=853</guid>

					<description><![CDATA[Problem Using the angular date pipe etc. we often see that by default the format is en-US instead of the expected browser language of the user. Solution What we have to do is quite simple:]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Problem</h2>



<p>Using the angular date pipe etc. we often see that by default the format is <code>en-US</code> instead of the expected browser language of the user.</p>



<h2 class="wp-block-heading">Solution</h2>



<p>What we have to do is quite simple:</p>



<ol class="wp-block-list">
<li>Import the locales we want to support</li>



<li>Register the locales</li>



<li>Configure <code>LOCALE_ID</code> <code>provider</code> using the browser language</li>
</ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application/typescript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;TypeScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;typescript&quot;}">import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

// 1. Import the locales we want to support, here we import just two
import localeDe from '@angular/common/locales/de';
import localeEn from '@angular/common/locales/en';
import { LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';

// other imports ...

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule,
	// other imports ...
  ],
  providers: [
    // 3. Configure LOCALE_ID provider using the browser language
    {provide: LOCALE_ID, useValue: navigator.language ?? 'en' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor() {
    // 2. Register the locales
    registerLocaleData(localeDe, 'de');
    registerLocaleData(localeEn, 'en');
  }
 }
</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://sterl.org/2023/01/angular-configure-user-browser-locale/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
