WordPress.org

Ready to get started?Download WordPress

Forums

Question about the days in calendar... (12 posts)

  1. citizenx
    Member
    Posted 10 years ago #

    Hi!
    I searched the forum and I didn't find the solution to my problem.
    First of all I would like to translate the days in calendar (S, M, T, W, etc.) to my own native language, Finnish. Wednesday starts with K in Finnish language. I already found wp-condig-extra.php and translated the days and months there. But how do I change the days in calendar?
    Second problem is that I want my week to start on monday. When I try to change the starting day from general blog settings, it has no effect. There is something wrong with it. How do I change they starting day?
    The version I'm using is WordPress 1.0.1
    Thank you.

  2. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    The week start setting has no effect on the calendar. There may be a locale setting in PHP you can change to have it use the correct days, but a sure way to be able to change it is to edit template-functions.php under get_calenday().

  3. Anavy
    Member
    Posted 10 years ago #

    I had the same problem (in Hebrew), so this is my solution:
    1. in wp-config-extra.php, build another array like this one:

    $shortweekday[0]='א';
    $shortweekday[1]='ב';
    $shortweekday[2]='ג';
    $shortweekday[3]='ד';
    $shortweekday[4]='ה';
    $shortweekday[5]='ו';
    $shortweekday[6]='ש';

    2. copy function get_calendar($daylength = 1) from template-functions.php (WP1.01) or template-functions-general.php (WP1.1) to my-hacks.php and rename it: my_get_calendar($daylength = 1) so you don't have to change it when you upgrade.
    3. In this function, change any $weekday (2 times, inc. the global declaration) to $shortweekday.
    That's all.

  4. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    Great instructions Anavy.

  5. Anavy
    Member
    Posted 10 years ago #

    thanks allusion. Can you consider adding this method to the Calendar function with a flag for choosing between $weekday and $shortweekday ?

  6. citizenx
    Member
    Posted 10 years ago #

    Thank you very much. :)

  7. Anonymous
    Unregistered
    Posted 10 years ago #

    You need to change the pre and post padding to different values. Just look for the according places in the get_calendar() function and change to this:
    [pre padding]
    // See how much we should pad in the beginning
    $pad = intval(date('w', $unixmonth));
    $pad = $pad + 6 % 7;
    if (0 != $pad) echo "\n\t\t<td colspan='$pad' class='pad'> </td>";
    [post padding]
    $foo = (date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))+6)%7;
    if ($foo != 0)
    $pad = 7 - $foo;
    else
    $pad = $foo;
    if (0 != $pad)
    echo "\n\t\t<td class='pad' colspan='$pad'> </td>";
    Maybe it's possible to do this more elegantly, but this one works. You can see it here
    HTH
    smo

  8. smo
    Member
    Posted 10 years ago #

    ups. You're right. I forgot something. in the same function look for the line that says
    if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
    Change the 6 to 0 and you're set.
    :)
    HTH
    smo

  9. citizenx
    Member
    Posted 10 years ago #

    Thank you. Now it works. :)

  10. smo
    Member
    Posted 10 years ago #

    jbygden, citizenx:
    please change to pre padding part to:
    $pad = ($pad + 6) % 7;
    Unfortunatly I forgot that % (the modulo operator) binds much stronger than the addition (+). So we have to put the addition in parenthesis. Now it should work.
    WordPress rules! :)
    smo

  11. jbygden
    Member
    Posted 10 years ago #

    Thanx smo,
    That did the trick.
    To allusion (or any other admin/developer that might read this), the week doesn't start Sunday in all parts of the world so this might be something to look at taking care of in the next release?

  12. Erkki
    Member
    Posted 10 years ago #

    Note for the newbies wasting their time with a messed up calendar (yes, I have to admit I did...)
    First of all you have to modify the starting day (default Sunday) in your wp-config-extra.php file, $weekday[0]='Monday' instead of 'Sunday' then and keep the list logical. BTW, it's the same process if you translate.
    Once done this mod will work smoothly :)
    Thank you smo :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags