[5.2.5] Supporting European locales?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gilles Ganault

    [5.2.5] Supporting European locales?

    Hello

    What does it take to support locales? The following test code found on
    the PHP site doesn't work as planned:

    =======
    setlocale(LC_TI ME, "C");
    echo strftime("%A");
    setlocale(LC_TI ME, "fi_FI");
    echo strftime(" in Finnish is %A,");
    setlocale(LC_TI ME, "fr_FR");
    echo strftime(" in French %A and");
    setlocale(LC_TI ME, "de_DE");
    echo strftime(" in German %A.\n");
    =======
    Wednesday in Finnish is Wednesday, in French Wednesday and in German
    Wednesday.
    =======

    I have a YYYY-MM-DD-formatted date in MySQL that I'd like to display
    as "Weekday DD/MM/YYYY".

    Do I need to recompile PHP or its extensions with a given switch, or
    do I need some extra libraries in Linux?

    Thank you.
  • Gilles Ganault

    #2
    Re: [5.2.5] Supporting European locales?

    On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <nospam@nospam. com>
    wrote:
    >What does it take to support locales? The following test code found on
    >the PHP site doesn't work as planned:
    For those interested, here's what I found out, on a FreeBSD 6.3 host:

    1. date() only uses the US locale, even if you call setlocale()
    beforehand.

    2. The following doesn't work:
    setlocale (LC_ALL, "fr_FR");
    setlocale (LC_TIME, "fr_FR");
    setlocale (LC_ALL, "fr-FR");
    setlocale (LC_TIME, "fr-FR");

    3. The following works:

    setlocale (LC_TIME, "fr_FR.ISO8 859-1");
    setlocale (LC_ALL, "fr_FR.ISO8 859-1");
    echo strftime("%a %d/%m/%Y",strtotime(" 2008-03-16"));

    HTH,

    Comment

    • Michael Fesser

      #3
      Re: [5.2.5] Supporting European locales?

      ..oO(Gilles Ganault)
      >On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <nospam@nospam. com>
      >wrote:
      >>What does it take to support locales? The following test code found on
      >>the PHP site doesn't work as planned:
      >
      >For those interested, here's what I found out, on a FreeBSD 6.3 host:
      >
      >1. date() only uses the US locale, even if you call setlocale()
      >beforehand.
      Correct. For locale-dependent output you have to use strftime().
      >2. The following doesn't work:
      >setlocale (LC_ALL, "fr_FR");
      >setlocale (LC_TIME, "fr_FR");
      >setlocale (LC_ALL, "fr-FR");
      >setlocale (LC_TIME, "fr-FR");
      >
      >3. The following works:
      >
      >setlocale (LC_TIME, "fr_FR.ISO8 859-1");
      >setlocale (LC_ALL, "fr_FR.ISO8 859-1");
      >echo strftime("%a %d/%m/%Y",strtotime(" 2008-03-16"));
      It always depends on which locales are installed on the system.

      Micha

      Comment

      • Gilles Ganault

        #4
        Re: [5.2.5] Supporting European locales?

        On Wed, 26 Mar 2008 22:20:40 +0100, Michael Fesser <netizen@gmx.de >
        wrote:
        >It always depends on which locales are installed on the system.
        Right. Use "locale -a" to find what locales are installed.

        Comment

        • AnrDaemon

          #5
          Re: [5.2.5] Supporting European locales?

          Greetings, Gilles Ganault.
          In reply to Your message dated Thursday, March 27, 2008, 02:26:52,
          >>It always depends on which locales are installed on the system.
          Right. Use "locale -a" to find what locales are installed.
          It is possible to access list of installed locales through PHP?
          Or, alternatively, where to get such list for the Windows host?


          --
          Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

          Comment

          Working...