ThemeShaper Forums » Thematic


Chnaging PHP Date String?

(3 posts)
  • Started 10 years ago by andycheeseman
  • Latest reply from middlesister
  • This topic is not resolved
  1. Hi,

    First of all, happy easter!

    Secondly... I'm wanting to change the display of the default calendar widget. I assume it is getting the day names and month names from PHP. Is there any way for me to change the string using functions.php? i.e...

    Monday = Funday
    Tuesday = Bluesday
    Wednesday = Breadensday

    And the same for the month names it displays?

    I'm wanting to display finnish titles without a full on translation.

    Posted 10 years ago #
  2. middlesister

    The day names and month names are not stored in php, but in language localization files. In wordpress they are stored in the directory wp-content/languages. I have read somewhere of someone who wanted to change the display strings and made a custom localization file with a custom locale. You would then define that custom locale in your wp-config

    define ('WPLANG', 'your_LOCALE');

    To read up on the localization process, visit
    To edit and compile localization files, I would recommend It is cross platform and open source.
    Basically you download a POT file from wordpress, open it in Poedit, make your desired 'translations' and save the file as your_LOCALE.po and as a
    Put the .po and .mo files in wp-content/languages (go ahead and create the directory if it is not there already).
    I am not sure, but I think that any strings left without translation simply will show untranslated. So you would only need to write something for the strings you want to change. And it would be a good idea to repeat the open-POT-and-save-po process with every wordpress update. Your strings will not get changed or deleted when you update wordpress so it is not strictly necessary, but it is a good idea to keep translation files in sync with the wordpress version.

    Unfortunately, specifying a locale in wp-config is site-wide. In PHP it is possible to temporarily switch locale with something like

    $old_locale = setlocale(LC_ALL, "0");
    setlocale(LC_ALL, "de_DE");
    // now use the geman locale
    setlocale(LC_ALL, $old_locale);
    // now use the original locale

    but I don't know how you would hook this in a wordpress widget (or even if it works in wordpress at all...). Thematic is excellent and comes with many hooks and filters, but the calendar widget is 1) a built in wordpress widget and 2) widgets by nature can be included anywhere so can be hard to target. If you can do without the 'widgetability', maybe you can call get_calendar() directly?

    function my_calendar() {
        // store the original locale
        $old_locale = setlocale(LC_ALL, "0");
        // change locale to a different one
        setlocale(LC_ALL, "your_LOCALE");
        // restore the locale
        setlocale(LC_ALL, $old_locale);

    This would add the calendar at the top of the sidebar. I haven't tested this myself, but if I wanted to do what you want to do, this what I would try. Let me know if it works :-)

    Posted 10 years ago #
  3. middlesister

    oh, and if you just want to use finnish names, why don't you download the finnish localization files, plonk them into wp-content/languages, and use the language switching code in functions.php. Then you wouldn't have to mess with .po files at all.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.