bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Add i18n to Datepicker

Open rsvalerio opened this issue 13 years ago • 11 comments

Or, in the meantime, is it possible to translate?

rsvalerio avatar Aug 07 '13 01:08 rsvalerio

You have to use a locale from AnularJS, since labels are created with the datefilter.

Example: http://plnkr.co/edit/7Fi5rO839elOeJwi5vH2?p=preview

bekos avatar Aug 07 '13 06:08 bekos

@bekos Yes, but I guess he means clear, today and close buttons.

MattiJarvinen-BA avatar Aug 07 '13 09:08 MattiJarvinen-BA

OK I see. If you talk about the popup datepicker, the way to translate the buttons in the bar, is to override the template. I suppose we could add some config for these labels for the next release. What about a PR? :-)

bekos avatar Aug 07 '13 11:08 bekos

OK I'll try :)

rsvalerio avatar Aug 08 '13 01:08 rsvalerio

@bekos There is no other way to translate the datepicker? The only way is modifying the index.html? In my application I identify the language of the user when it performs login. That is, the index is already configured.

ThCC avatar Sep 27 '13 19:09 ThCC

@ThCC The real problem is that you cannot change your $locale during runtime, or at least I don't know of a way to do this. Even if you solve the problem with the datepicker, you will still have problem in every other filter that is locale dependent, like currency.

I think it is better to ask a more general question in the AngularJS issues.

bekos avatar Sep 30 '13 13:09 bekos

Thanks for answering @bekos, I'll see what I can do.

ThCC avatar Sep 30 '13 13:09 ThCC

You can check this project http://pascalprecht.github.io/angular-translate/ to see if it helps. In case you find a solution please get back to us :-)

bekos avatar Sep 30 '13 13:09 bekos

Again thank you. I'm using this component in the project, but I'll see if I can use it in conjunction with the datepicker. If I succeed I will return to tell you ;)

ThCC avatar Sep 30 '13 14:09 ThCC

@ThCC can you tell us if the angular-translate works in conjunction with the datepicker?

vladei avatar Oct 07 '15 11:10 vladei

It works for the names of days and months, but not the texts Today / Clear / Done

Anyone looking for a quickfix, you can override the config:

var app = angular.module('myapp', ['ui.bootstrap']);
    app.constant('uibDatepickerPopupConfig', {
        datepickerPopup: 'yyyy-MM-dd',
        datepickerPopupTemplateUrl: 'template/datepicker/popup.html',
        datepickerTemplateUrl: 'template/datepicker/datepicker.html',
        html5Types: {
            date: 'yyyy-MM-dd',
            'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',
            'month': 'yyyy-MM'
        },
        currentText: 'Vandaag',
        clearText: 'Wissen',
        closeText: 'Klaar',
        closeOnDateSelection: true,
        appendToBody: false,
        showButtonBar: true,
        onOpenFocus: true
    });

rbaarsma avatar Dec 04 '15 09:12 rbaarsma