Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  178] [ 6]  / answers: 1 / hits: 79373  / 10 Years ago, tue, october 21, 2014, 12:00:00

I'm using bootstrap-datepaginator that inside uses bootstrap-datepicker.
Utilizzanto bootstrap-datepicker as a single component, there are no problems to set the language, but the same is not true using bootstrap-datepaginator. How can I do?



I'm trying to set the Italian language as a default for the entire project.
In index.html I put the following script:



<script src=vendors/bootstrap-datepicker/js/bootstrap-datepicker.js></script>
<script src=vendors/jquery-ui/ui/i18n/datepicker-it.js></script>

<script>
$(function() {
$( #datepicker ).datepicker( $.datepicker.regional[ it ] );
});
</script>


But in the console I get these errors:



Uncaught TypeError: Cannot read property 'regional' of undefined datepicker-it.js:15
Uncaught TypeError: Cannot read property 'regional' of undefined (index):394


I tried everything but I'm going crazy!



Bootstrap Datepicker i18n






I changed the code in this way:



<script src=vendors/bootstrap-datepicker/js/bootstrap-datepicker.js></script>
<script src=vendors/bootstrap-datepicker/js/locales/bootstrap-datepicker.it.js></script>


<script>
$(function() {
$.datepicker.setDefaults( $.datepicker.regional[it] );
});
</script>


but now the error is as follows:



Uncaught TypeError: Cannot read property 'setDefaults' of undefined





With this fix:



$('.datepicker').datepicker({
language: it
});


I haven't got errors in console but the language is always english by default


More From » angularjs

 Answers
161

You can set default options for Bootstrap Datepicker by assigning them like so:



$.fn.datepicker.defaults.language = 'it';


Example below:





$(document).ready(function(){
$.fn.datepicker.defaults.language = 'it';
});

$(document).ready(function(){
$('.datepicker').datepicker();
});

<link href=https://cdn.jsdelivr.net/bootstrap.datepicker-fork/1.3.0/css/datepicker3.css rel=stylesheet/>
<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js></script>
<script src=https://cdn.jsdelivr.net/bootstrap.datepicker-fork/1.3.0/js/bootstrap-datepicker.js></script>
<script src=https://cdn.jsdelivr.net/bootstrap.datepicker-fork/1.3.0/js/locales/bootstrap-datepicker.it.js></script>
<input class=datepicker/>




[#69056] Sunday, October 19, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elishaannac

Total Points: 28
Total Questions: 97
Total Answers: 101

Location: Samoa
Member since Mon, Nov 8, 2021
3 Years ago
elishaannac questions
Sun, Dec 5, 21, 00:00, 3 Years ago
Mon, Jun 14, 21, 00:00, 3 Years ago
Mon, Jul 22, 19, 00:00, 5 Years ago
Mon, Jul 8, 19, 00:00, 5 Years ago
;