Code Monkey home page Code Monkey logo

Comments (3)

ThCC avatar ThCC commented on June 6, 2024

Good morning, not wanting to be annoying, and forgive me if I'm being, but I really need to know how to modify the language of the ui-date. Can you help me?

from ui-date.

 avatar commented on June 6, 2024

Not trivial. I'm assuming you use this angular translate to handle your translations. The way I did it:
In index.html, include the languages you want to be able to display:

<script src="js/vendor/i18n/jquery.ui.datepicker-en.js"></script>
<script src="js/vendor/i18n/jquery.ui.datepicker-lb.js"></script>
<script src="js/vendor/i18n/jquery.ui.datepicker-pt-BR.js"></script>
<script src="js/vendor/i18n/jquery.ui.datepicker-tr.js"></script>
<script src="js/vendor/i18n/jquery.ui.datepicker-fr.js"></script>

Then in your controller, extend $scope.dateOptions with the language you're using:

// JQuery UI date options
$scope.dateOptions = {
    minDate: 0,
    dateFormat: ninja_config.l10n.ui_date
};
angular.extend($scope.dateOptions, jQuery.datepicker.regional[$translate.uses()]);

Also add a listener to be able to change the language dynamically:

// Translates the datepicker whenever the language changes.
$scope.$on('$translateChangeSuccess', function () {
    var language = $translate.uses();
    $log.debug('Changing datepicker language to ' + language);
    angular.extend($scope.dateOptions, jQuery.datepicker.regional[language]);
});

from ui-date.

zengchuan avatar zengchuan commented on June 6, 2024

How to inject jQuery in jQuery.datepicker.regional ?

from ui-date.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.