Page 1 of 1
First day of the week
Posted: Sat Mar 19, 2016 12:08 am
by yorgil
Hello,
It is my first post so please forgive me if this question is trivial...
I use OpenCart 2.1.0.2 hosted on Siteground
In Poland we have standard calendars with Sunday as last day of week instead of first. But in my OC shop (even i have set it to polish) my calendar has Sunday as first day of week and it is in english (not translated). I cant find any texts in language directory files to make a translation. But more important issue is with days of week. How can i change week format to make Monday first day and Sunday 7th?
Regards
Przemek
Re: First day of the week
Posted: Sun Mar 20, 2016 9:16 pm
by Qphoria
Re: First day of the week
Posted: Sun Mar 20, 2016 10:36 pm
by yorgil
Thank you, but this is post about different datapicker - by eternicode.
I have installation of Opencart 2.1.0.2 where is datapicker eonasdan version 3.1.3
https://github.com/Eonasdan/bootstrap-datetimepicker
It doesnt support weekStart option.
It seems i can use code like this:
Code: Select all
$('#DateTime').datetimepicker({
language: "pl"
});
But i have no idea where I have to add this option - there are many file where .datetimepicker({ exists.
I tried also to change moment.js file and set there:
but id doesnt work too.
Also here is discussion that with this datpicker is very hard or imposible to change week format:
http://stackoverflow.com/questions/2441 ... -at-monday
Is there any chance to switch to another datapicker? And if you be so kind, how can i do it?
Re: First day of the week
Posted: Sun Mar 20, 2016 11:55 pm
by ocart777
well im not sure if this will cause any error, but this do the trick for me. if you want to take the risk simply follow this steps.
admin/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js
search for
Code: Select all
if (moment().localeData()._week.dow === 0) {
change to
Code: Select all
if (moment().localeData()._week.dow === 1) {
catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js
search for
replace with
Re: First day of the week
Posted: Mon Mar 21, 2016 12:18 am
by yorgil
It not exactly what I awant to achieve. Those modifications change daysnames at top of calendar but entire calendar stays as it was before - so daynames dont correspond with proper dates.
I think there is necessity to change language/local of that datapicker. Even when i change week format i still need translated whole calendar.
Re: First day of the week
Posted: Mon Mar 21, 2016 12:36 am
by ocart777
ok, i've found the solution for this after reading their docs file. all you need is pick your locale from
https://github.com/moment/moment/tree/develop/locale and save the (.js) file into your "admin/view/javascript/jquery/datetimepicker/" directory. as example my locale file name is "ms-my.js", so..
admin/view/template/common/header.tpl
after
Code: Select all
<script src="view/javascript/jquery/datetimepicker/moment.js" type="text/javascript">
add
Code: Select all
<script src="view/javascript/jquery/datetimepicker/ms-my.js" type="text/javascript"></script>
<script type="text/javascript"><!--
moment.locale('ms-my');
//--></script>
please note that you also need to do this for catalog(front end)
Re: First day of the week
Posted: Mon Mar 21, 2016 1:40 am
by yorgil
Please forgive me but im not sure what i have to do.
I uploaded pl.js file
I cant find
Code: Select all
<script src="view/javascript/jquery/datetimepicker/moment.js" type="text/javascript">
in catalog/view/theme/default/template/common/header.tpl
And in admin - why there are those comments? And should not there be
tag at the end of line after which i have to add rest of your code?
Re: First day of the week
Posted: Mon Mar 21, 2016 2:18 am
by ocart777
in catalog header.tpl, you can add before "<?php foreach ($analytics as $analytic) { ?>", it isn't showing directly but you still can see them by viewing page source. just make sure that you pointing to the pl.js correctly
Re: First day of the week
Posted: Mon Mar 21, 2016 6:13 pm
by yorgil
I dont know what is wrong wuth me... I cant make it working...
I uploaded file pl.js to
/admin/view/javascript/jquery/datetimepicker
and to
/catalog/view/javascript/jquery/datetimepicker
Then as suggested i edited file /admin/view/template/common/header.tpl
After line
Code: Select all
<script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
i have now
Code: Select all
<script src="view/javascript/jquery/datetimepicker/moment.js" type="text/javascript">
<script src="view/javascript/jquery/datetimepicker/pl.js" type="text/javascript"></script>
<script type="text/javascript"><!--moment.locale('pl');//--></script>
</script>
<script src="view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link href="view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" media="screen" />
Then i edited file /catalog/view/theme/default/template/common/header.tpl
Before line
Code: Select all
<?php foreach ($analytics as $analytic) { ?>
I have now
Code: Select all
<script src="view/javascript/jquery/datetimepicker/pl.js" type="text/javascript"></script>
<script type="text/javascript"><!--moment.locale('pl');//--></script>
I wonder what for are those comments there. After whole weekend with this im resigned... And it still doesnt work.
Re: First day of the week
Posted: Mon Mar 21, 2016 9:12 pm
by yorgil
OK, i tried to rework all modifications again and i have partial success.
In admin/view/template/common/header.tpl i just added:
Code: Select all
<script src="view/javascript/jquery/datetimepicker/moment.js" type="text/javascript"></script>
<script src="view/javascript/jquery/datetimepicker/pl.js" type="text/javascript"></script>
<script>moment.locale('pl');</script>
and in admin it works! - I have polish calendars with monday as first day
Unfortunatelly in front it doesnt work - and i have no idea why...
I added in catalog/view/theme/default/template/common/header.tpl
Code: Select all
<script>moment.locale('pl');</script>
Line with moment.js is added there earlier bye script in header.tpl.
Looks very similar to admin part - in source links are correct. But it still doesnt work.