angular-datepicker icon indicating copy to clipboard operation
angular-datepicker copied to clipboard

Configure language

Open falinsin opened this issue 8 years ago • 13 comments

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

falinsin avatar Jan 12 '16 14:01 falinsin

https://docs.angularjs.org/guide/i18n

eralha avatar Jan 12 '16 14:01 eralha

+1

Sofianio avatar Jan 12 '16 14:01 Sofianio

Why close? i added fr_fr.js but it still shows jan feb mar apr...

Sofianio avatar Jan 12 '16 14:01 Sofianio

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?

eralha avatar Jan 12 '16 15:01 eralha

Yes & still January February ....

Sofianio avatar Jan 12 '16 15:01 Sofianio

hmmm maybe its related with moment locale...

eralha avatar Jan 12 '16 15:01 eralha

tried to set it to fr ... nothing

Sofianio avatar Jan 12 '16 15:01 Sofianio

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');

DanTalash avatar Jan 14 '16 17:01 DanTalash

Thank you @eralha & @DanTalash now it works (i added moment's fr.js but forgot to include it in html).

Sofianio avatar Jan 16 '16 11:01 Sofianio

since this isn't closed yet can i ask how to show date picker only (no time) thank you.

Sofianio avatar Jan 18 '16 16:01 Sofianio

@Sofianio check out the minView attributes. Setting minView to 'date' will disallow selecting times (only years, months, and days will be selectable)

DanTalash avatar Jan 19 '16 19:01 DanTalash

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)

Sofianio avatar Jan 28 '16 12:01 Sofianio

Thank you for your comments and help.

falinsin avatar Feb 04 '16 18:02 falinsin