-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
docs(datetimepicker): internationalization #141
Labels
Comments
nzbin
added
docs
This issue is related to docs
area: datetimepicker
Issues about datetimepicker
labels
Oct 23, 2022
This was referenced Jul 11, 2023
How do I do if I want to translate the name of the months and days? |
I'm currently struggling with internationalization. The popup changes correctly (Date format, date language) when I switch the language, but the manual input always defaults to English. Could you please help me? My setup
in main.ts I provide :
And in my component I provide:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Setting the locale code
It also needs
MAT_DATE_LOCALE
injection token to customize the locale code. Please check the Material docs:https://material.angular.io/components/datepicker/overview#setting-the-locale-code
Choosing a date implementation and date format settings
MtxNativeDatetimeModule
MtxMomentDatetimeModule
MtxLuxonDatetimeModule
MtxDateFnsDatetimeModule
Customizing the parse and display formats
The
MTX_DATETIME_FORMATS
object is a collection of formats that the datetimepicker uses when parsing and displaying dates. These formats are passed through to theDatetimeAdapter
so you will want to make sure that the format objects you're using are compatible with theDatetimeAdapter
used in your app.If you want use one of the
DatetimeAdapter
that ships with Angular Material, but use your ownMTX_DATETIME_FORMATS
, you can import theNativeDatetimeModule
orMomentDatetimeModule
. These modules are identical to the "Mtx"-prefixed versions (MtxNativeDatetimeModule
andMtxMomentDatetimeModule
) except they do not include the default formats.For moment adapter
For luxon adapter
Check the PR #138
For date-fns adapter
Check the PR #140
Localizing labels and messages
The various text strings used by the datetimepicker are provided through MtxDatetimepickerIntl. Localization of these messages can be done by providing a subclass with translated values in your application root module.
The text was updated successfully, but these errors were encountered: