Introduction
Sometimes we get a requirement to implement localization in our website. Localization means browser display data in different language as per browser setting or manual setting inside application. So this article helps to implement jQuery Datepicker to display in different languages as per browser settings. Before going through this article I would suggest you to visit here, that might help you more.
Let’s discuss how it can be implemented:
Step 1: Add the following JavaScript references.
Sometimes we get a requirement to implement localization in our website. Localization means browser display data in different language as per browser setting or manual setting inside application. So this article helps to implement jQuery Datepicker to display in different languages as per browser settings. Before going through this article I would suggest you to visit here, that might help you more.
Let’s discuss how it can be implemented:
Step 1: Add the following JavaScript references.
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
- <link href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
- <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/i18n/jquery-ui-i18n.min.js"></script>
Step 2: Fetch browser language version using JavaScript. Here is the code:
- var userLang = navigator.language || navigator.userLanguage;
Step 3: Add the following JavaScript code to implement localization in jQuery Datepicker. Here we are using extend property to set regional language as per the browser setting (Step 2).
- var options = $.extend(
- {}, // empty object
- $.datepicker.regional[userLang], // Dynamically
- { dateFormat: "mm/dd/yy"} // your custom options
- );
- $("#calendar").datepicker(options);
Putting all together, here is the complete code:
- <!doctype html>
- <html lang="en">
- <head>
- <title>Localization JQuery UI Datepicker </title>
- <meta charset="utf-8">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
- <link href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
- <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/i18n/jquery-ui-i18n.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- var userLang = navigator.language || navigator.userLanguage;
- var options = $.extend({}, // empty object
- $.datepicker.regional[userLang], {
- dateFormat: "mm/dd/yy"
- } // your custom options
- );
- $("#calendar").datepicker(options);
- });
- </script>
- </head>
- <body>
- <div class="container">
- <h3>JQuery UI Datepicker Localization</h3>
- <div id="calendar"> </div>
- </div>
- </body>
- </html>



Priya LallPosted Jun 26, 2019, 1:47 AM
I am not able to get it
Sibeesh VenuPosted Sep 28, 2015, 3:16 AM
Thanks for the share
Humayun Kabir MamunPosted Sep 28, 2015, 2:21 AM
Nice...
Ankit BansalPosted Sep 28, 2015, 12:52 AM
nice one..thanks ..
Harshad PansuriyaPosted Sep 28, 2015, 12:36 AM
Nice One
Vinodh NarayananPosted Sep 27, 2015, 8:59 AM
nice share[
Pankaj Kumar ChoudharyPosted Sep 27, 2015, 6:01 AM
Nice Article.........
Raja TPosted Sep 27, 2015, 4:00 AM
Nice, Good one....
Raja TPosted Sep 27, 2015, 3:40 AM
Thanks for sharing
Santhakumar MunuswamyPosted Sep 27, 2015, 3:01 AM
Good Article
RakeshPosted Sep 27, 2015, 1:39 AM
Good Article Share