angular-datepicker
angular-datepicker copied to clipboard
Configure language
Is it possible use languages apart from english??
Can i changue the language? Is there something in the API for accomplish this??
Thanks in advance for your sure help because it is very important fo me
https://docs.angularjs.org/guide/i18n
+1
Why close? i added fr_fr.js but it still shows jan feb mar apr...
The translation is a layer above this module, it's not an issue here. Did you added this file https://github.com/angular/angular.js/blob/master/src/ngLocale/angular-locale_fr-fr.js ? Did you added "ngLocale" as a dependency of your app?
Yes & still January February ....
hmmm maybe its related with moment locale...
tried to set it to fr ... nothing
You need to switch the moment locale in order to have the dates localized to whatever language you want.
See this section from the moment docs.
You will need to set up the moment locale while configuring your application. Copying this code from the docs and running it in the demo application causes the language to switch to French:
moment.locale('fr', {
months : "janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),
monthsShort : "janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),
weekdays : "dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),
weekdaysShort : "dim._lun._mar._mer._jeu._ven._sam.".split("_"),
weekdaysMin : "Di_Lu_Ma_Me_Je_Ve_Sa".split("_"),
longDateFormat : {
LT : "HH:mm",
LTS : "HH:mm:ss",
L : "DD/MM/YYYY",
LL : "D MMMM YYYY",
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
calendar : {
sameDay: "[Aujourd'hui à] LT",
nextDay: '[Demain à] LT',
nextWeek: 'dddd [à] LT',
lastDay: '[Hier à] LT',
lastWeek: 'dddd [dernier à] LT',
sameElse: 'L'
},
relativeTime : {
future : "dans %s",
past : "il y a %s",
s : "quelques secondes",
m : "une minute",
mm : "%d minutes",
h : "une heure",
hh : "%d heures",
d : "un jour",
dd : "%d jours",
M : "un mois",
MM : "%d mois",
y : "une année",
yy : "%d années"
},
ordinalParse : /\d{1,2}(er|ème)/,
ordinal : function (number) {
return number + (number === 1 ? 'er' : 'ème');
},
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
},
// in case the meridiem units are not separated around 12, then implement
// this function (look at locale/id.js for an example)
// meridiemHour : function (hour, meridiem) {
// return /* 0-23 hour, given meridiem token and hour 1-12 */
// },
meridiem : function (hours, minutes, isLower) {
return hours < 12 ? 'PD' : 'MD';
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
}
});
Of course, if your moment version includes the locale definition, then all you need to switch is to call something like moment.locale('fr');
Thank you @eralha & @DanTalash now it works (i added moment's fr.js but forgot to include it in html).
since this isn't closed yet can i ask how to show date picker only (no time) thank you.
@Sofianio check out the minView attributes. Setting minView to 'date' will disallow selecting times (only years, months, and days will be selectable)
Another question: when my input is empty it becomes invalid thus the form is invalid ... i want to make the date optional, how do i do that (i get pattern error)
Thank you for your comments and help.