-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I can not find locale for pt-BR on angular 5 #20197
Comments
Please read https://angular.io/guide/i18n#i18n-pipes By the way, the issue tracker is not a place for support requests. Please ask for such requests at StackOverflow and tag the question with |
cc @ocombe |
Hello, according to CLDR Portuguese (Brazil) [pt_BR] is the default content locale for Portuguese [pt], which means that you should import from "pt". See this example: https://stackblitz.com/edit/angular-moddkn?file=app%2Fapp.module.ts As you can see here: https://github.com/angular/angular/blob/master/packages/common/locales/pt.ts#L45 the currency for "pt" is "Real brasileiro" which is the currency from Brazil. |
I added both LOCAL_ID and called the registerLocaleData(locale) to get it working properly. import { LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localePt from '@angular/common/locales/pt';
registerLocaleData(localePt);
@NgModule({
providers: [
{ provide: LOCALE_ID, useValue: 'pt-BR' }
]
})
export class AppModule { } |
You should be able to do: import { LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localePt from '@angular/common/locales/pt';
registerLocaleData(localePt, 'pt-BR');
@NgModule({
providers: [
{ provide: LOCALE_ID, useValue: 'pt-BR' }
]
})
export class AppModule { } This will make sure that you register the locale with the exact LOCALE_ID that you defined |
import { NgModule, LOCALE_ID } from '@angular/core'; import { AppComponent } from './app.component'; import { registerLocaleData } from '@angular/common'; @NgModule({ |
@ocombe nice example, works fine. import { NgModule, LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import ptBr from '@angular/common/locales/pt';
registerLocaleData(ptBr)
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent, HelloComponent],
providers: [{ provide: LOCALE_ID, useValue: 'pt' }],
bootstrap: [AppComponent]
})
export class AppModule { } From the example: https://stackblitz.com/edit/angular-moddkn?file=app%2Fapp.module.ts |
Default Portuguese locale should be pt-PT, there's no valid reason for it to be pt-BR. |
We follow the rules of CLDR on this, if you have an issue with their choices, you can open an issue here: http://cldr.unicode.org/index/bug-reports |
By default, Angular only contains locale data for en-US. If you set the value of LOCALE_ID to another locale, you must import locale data for that new locale. The CLI imports the locale data for you when you use the parameter --locale with ng serve and ng build. If you want to import locale data for other languages, you can do it manually: src/app/app.module.ts registerLocaleData(localeFr); src/app/app.module.ts registerLocaleData(localeFrCa, localeFrCaExtra);
To portugues, you can use this snippet, beleza 👍 ?
|
Hi, I have import the locate 'pt' like you show app.module.ts
https://stackblitz.com/edit/angular-locale-pt?embed=1&file=app/app.module.ts You have some idea? |
Do you have an example of this? Maybe on stackblitz? |
Yes @ocombe, I writed an exemple now. https://stackblitz.com/edit/angular-locale-pt?embed=1&file=app/app.module.ts |
The currency itself doesn't change with the language, you have to use a different currency code for that (which is what you did in your stackblitz example). |
I really dont get this.. when i use the currency pipe like this it changes the $ to R$..
Shouldnt this have the same behaviour? |
If you say that you want bresilian real (BRL) then the symbol is $R in english (to avoid the confusion with $ for american dollar). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
Hi, I can not find locale for pt-BR on angular 5
Minimal reproduction of the problem with instructions
providers: [
{ provide: LOCALE_ID, useValue: 'pt-PT'}
]
Error: Missing locale data for the locale "pt-BR"
What is the motivation / use case for changing the behavior?
Environment
Angular version: 5.0.0
The text was updated successfully, but these errors were encountered: