-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
import locale for angular #6843
Conversation
Thanks @ctamisier |
thanks for testing, good point because it's not working with: What I think (from the table in https://angular.io/guide/i18n#setting-up-the-locale-of-your-app): |
be442fd
to
e494e37
Compare
Or maybe we should just update the values of |
@@ -18,6 +18,16 @@ | |||
-%> | |||
import { NgModule, LOCALE_ID } from '@angular/core'; | |||
import { Title } from '@angular/platform-browser'; | |||
import { registerLocaleData } from '@angular/common'; | |||
<%_ const localeIds = { | |||
'zh-cn': 'zh-Hans', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add a new attribute to the original language object in generator-constants so that this is not hidden, then fetch the value from that object lile how we do for rtl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
export class <%=angularXAppName%>SharedCommonModule {} | ||
export class <%=angularXAppName%>SharedCommonModule { | ||
constructor() { | ||
registerLocaleData(locale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just ensure that this works fine with AOT as it has history of not working with normal js constructs sometimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum :), I don't know what this really means... can you guide me a bit on this ? thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just run the app using ./mvnw -Pprod
and make sure everything works fine, as this will use AOT and if there is an issue here it should fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So everything seems to work fine with this. Running ./mvnw -Pprod
compiles and runs with no problem. Then in the app everything is fine as well, I tried with different locales, so it's all good for me.
yeah it's indeed a better idea. There is the case of |
@ctamisier for |
If we use Then if we switch to english language it shows It wouldn't be a problem if we could change the localeId runtime which not doable today (angular/angular#15039). So I left the |
Just to aggregate some info here, I'm from Brazil and therefore I am always using pt-BR and the solution I have found was to change from pt-br to pt-BR everywhere because there is a case sensitive matter on the language code. Also using only 'pt' is more common use to only portuguese from Portugal which is quite different from brazilian portuguese and we will keep using pt-BR here to not use funny words that we don't use as Portugal people does heheheheeh. |
thanks @marcelinobadin for your input.
I guess Angular decided to design this way.. or I might misunderstand something ? |
Fix for #6836. Let's see about the coding rules (using a constructor ?)
check 'Pipes, i18n and breaking changes' in http://blog.ninja-squad.com/2017/11/02/what-is-new-angular-5/