• In the header of my theme, I am displaying the current date in a written out format, at the top right side. The site is multilingual and the date language should change with the user locale. This used to work at one point, but it no longer does.

    There have been no changes to this part of the theme code since. The site has only received maintenance updates (major and minor WordPress versions; plug-in updates). It is currently on WP 5.0.3.

    I updated the language files for the secondary language (Dutch) with those from the 5.0.3 NL install package, to no avail.

    This is the code in the theme for outputting the date:

    date_default_timezone_set('Europe/Brussels');
    echo date_i18n( get_option( 'date_format' ));

    In English (/en/) the date reads:
    Monday, 28 January 2019

    In Dutch (nl_NL; /nl/), it should read:
    Maandag 28 january 2019

    But instead, it reads:
    Monday 28 January 2019

    It is using the date formatting from the WordPress settings (I’m using PolyLang by the way). This is working correctly: when using Dutch for the locale, the comma in the date is omitted.

    Currently, I’m at a loss for what else to check for…

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Changing the timezone doesn’t change the language or the locale of the site. That’s just the default timezone setting.

    Thread Starter dalsegnoalfine

    (@dalsegnoalfine)

    That is correct, the issue is with the second line, with the function date_i18n(). It should output the names of days and months in the language of the user locale.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Right, but, what is the locale? You don’t show setting that, you just show changing the timezone.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    You may want to ask the PolyLang authors for help directly. They know what and how their plugin works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘date_i18n always returns English names for day and month’ is closed to new replies.