ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

A charset problem...

March 03, 2008 6:03pm

Subscribe [1]
  • #1 / Mar 03, 2008 6:03pm

    Peter Sommerfeld

    86 posts

    For a bi-lingual site german/english I have to hack date-output (see this thread). Here is my PHP-Code for the monthly archive links (german template).

    <div class="subtitle">Monatliches Archiv  (12 Monate)</div>
    <ul>
    {exp:weblog:month_links weblog="{embed:blog}" limit="12"}
    <li><a href="http://{path={embed:blog}/index}">_<?php_setlocale (LC_TIME, 'de_DE'); _echo strftime('%B %Y ',strtotime("{month} {year}"));_?>_</a></li>
    {/exp:weblog:month_links}
    </ul>

    The output with Firefox on Vista is correct:

    * Februar 2008 (February 2008)
    * Januar 2008 (January 2008)

    To my surprise it is wrong on IE-7/Vista, IE-6/XP and Firefox/Ubuntu. They show:

    * Dezember 1969 (December 1969)
    * Dezember 1969

    HTML is validated, the header:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="{language_code}"  />

    I’ve also tried “setlocale (LC_TIME, ‘de_DE.UTF-8’);” but that does not fix it.

    I have no clue how to fix that. Any ideas?

    Peter

    PS: the url(without http) irish-terrier.eu/de/journal/

  • #2 / Mar 03, 2008 7:33pm

    Sue Crocker

    26054 posts

    Freund Peter..

    What happens if you create a stand alone PHP page where you’d be passing {month} and {year} to it?

    Or if you echo out the value of {month} and {year} to the script before trying setlocale?

    Are you parsing PHP as input or output?

  • #3 / Mar 03, 2008 8:57pm

    Peter Sommerfeld

    86 posts

    Hi Sue!

    The echo of the value of {month} and {year} to the script before trying setlocale is the same as before except that it is not translated to german [echo strftime(’%B %Y ‘,strtotime(”{month} {year}”));]
    Firefox/Vista OK, the others December 1969.

    I’m parsing output as suggested in this thread.

    I think there must be something with the interpretation of the charset because December 1969 is just before 1.1.1970 when the unix-timestamp starts, - handling of negative values or something like this.

    PHP4 on EE-Hosting if that matters.

    Peter

  • #4 / Mar 03, 2008 9:22pm

    Sue Crocker

    26054 posts

    Peter, I used your same code on a sample page, and after hard coding the weblog name, and the path= path.
    Support Test: Setlocale

    I looked at it in IE7 with Vista and Firefox with Vista.

    See if hard coding helps you since this looks like a part of another page.

  • #5 / Mar 03, 2008 9:59pm

    Peter Sommerfeld

    86 posts

    Sue, your example looks good on all browsers !

    See if hard coding helps you since this looks like a part of another page.

    No, that does not help.

    I send you access data via pm in case you want to look into the code.

    I’ll continue tomorrow, here it is 3:00 am — means: after midnight 😊

    thanks

    Peter

  • #6 / Mar 03, 2008 10:07pm

    Sue Crocker

    26054 posts

    Guten Nacht. I’ll be continuing it in the morning as well.

  • #7 / Mar 04, 2008 3:25am

    Peter Sommerfeld

    86 posts

    Guten Morgen Sue!

    I’ve set up a plain page with hardcoded weblog/path on
    /de/site/test/
    Still the same ...

    Peter

  • #8 / Mar 04, 2008 9:11am

    Sue Crocker

    26054 posts

    Take a look at your test template. I added some debug code. You’ll see that you don’t need to use the PHP code.

    I viewed the same template as a non-logged in user, and saw the same thing.

  • #9 / Mar 04, 2008 10:34am

    Peter Sommerfeld

    86 posts

    I see, but that is not the point. PHP is needed to switch between the language-context:

    /de/site/test or /de/journal/ (everything in german)
    vs.
    /en/site/test or /en/journal/ (everything in english)

    Without PHP either the user-settings are used or the default-setting. You must switch in the Control Panel to english to see that.

    But you pointed me probably onto the right track. I’ve used as default-language “deutsch” (Admin ›  System Preferences ›  General Configuration) what probably means that “{month} {year}” give back the german names and that cannot be translated by the PHP-Function. After switching to english it is still obscure: IE-7 on Vista and Firefox on Vista both show the correct output but Firefox on Linux still Dezember 1969. Cannot check XP currently.

    I’ll dig into this later on evening…

    Peter

  • #10 / Mar 04, 2008 6:17pm

    Peter Sommerfeld

    86 posts

    Hi Sue !

    The default language settings are definitely the origin of all. It works well now on Firefox/XP and IE-6/XP too, still Firefox/Ubuntu resists. But I know from others that Firefox/Ubuntu is very sensitive and stop looking into that issue for now. I’ll first implement the complete language switch and than look into it again, - or even skip it.

    Thanks a lot for you support!

    Peter

    PS: Multi-language as well as localisation is a mess…

  • #11 / Mar 04, 2008 6:54pm

    Sue Crocker

    26054 posts

    Glad you were able to figure it out. I spent a bit of time looking to see if I could find any other options, but they just didn’t work.

    Have you looked through the wiki for other items on multiple language sites?

  • #12 / Mar 04, 2008 8:33pm

    Peter Sommerfeld

    86 posts

    Have you looked through the wiki for other items on multiple language sites?

    Sure, but I’ve to deal with a few special cases, mixing up languages in one thread, independent translations and such. So I expect a few more problems. I will see…

    thanks again

    Peter

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases