We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    Thanks to Nissai for this one. Maybe it’s old news to some of you but including SetLocale in the language file allow for date localization, site wide grin

    Example for francais.inc.php :
    setlocale (LC_ALL, 'fr_FR');


    Refer to SetLocale doc to set your country’s code.

    I think we should all add this to the language file, so that users don’t have to do anything about date localization.

      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 22303 MODX Staff
      • 10,725 Posts
      Great stuff -- can we make sure that gets a task in the tracker David? Just so we can keep track of such great feature enhancements. wink
        • 34162
        • 1 Posts
        I just want to point that this is not thread safe and the number representation will work differently for mysql or search string when the setlocal is activated.
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: chanh at Feb 28, 2006, 02:40 PM

          I just want to point that this is not thread safe and the number representation will work differently for mysql or search string when the setlocal is activated.

          Chanh, can you please explain what you mean? I’m not following. Or some references to external discussions on the topic would be fine.
            • 32241
            • 1,495 Posts
            Yeap, I would like to know more about this.
            I can see the use of this on the type of ASP .Net application, but for PHP, I still think ther eis a limitation. When we setlocale, what function does this thing affect, and how about mysql processing and etc.

            Any further info about this will be great, considering I’m still new to this kind of thing on PHP.

            Thanks
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              http://il2.php.net/setlocale

              A lot of comments discussing this.

                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 6726
                • 7,075 Posts
                Quote from: OpenGeek at Feb 28, 2006, 02:01 PM

                Great stuff -- can we make sure that gets a task in the tracker David? Just so we can keep track of such great feature enhancements. wink

                I sure can, and I’ll do it right now so that I don’t forget. Done

                We have to check if this causes any problem though...

                Edit : Followed Susan’s link, there is indeed a Warning as Chanh said :

                WarningThe locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server api like IIS or Apache on Windows you may experience sudden changes of locale settings while a script is running although the script itself never called setlocale() itself. This happens due to other scripts running in different threads of the same process at the same time changing the processwide locale using setlocale().

                It would only create problem on Windows environment if I understand correctly...
                Wouldn’t there be a way to have Windows environment ignore those lines (like an escape syntax or whatever) ?
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 32241
                  • 1,495 Posts
                  It’s on my todo list for this week >:(
                  http://www.opengroup.org/onlinepubs/007908799/xbd/locale.html

                  Hope I can survive readint his whole doc. grin
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media
                    • 32241
                    • 1,495 Posts
                    Another problem

                    Be carefull - setting a locale which uses commas instead of dots in numbers may cause a mysql db not to understand the query:
                    <?php
                    setlocale(LC_ALL,"pl");
                    $price = 1234 / 100; // now the price looks like 12,34
                    $query = mysql_query("SELECT Id FROM table WHERE price=’".$price."’");
                    ?>
                    Even if there is a price 12.34 - nothing will be found

                    Do you guys think implementing our own locale will be much better?
                    All we need to do is to let each language file define the currency code, coma or dot, and bla bla bla. MODx will use this as the output and input. I’ll need to research this further, because it seems to me that the current setlocale functionality is not as mature as the one provided by ASP .Net. Is there any changes in PHP5 for this capability?
                      Wendy Novianto
                      [font=Verdana]PT DJAMOER Technology Media
                      [font=Verdana]Xituz Media
                      • 6726
                      • 7,075 Posts
                      Wendy, do you sleep sometimes grin ?!? You’re on so many front it sure looks like you don’t...

                      Anyway, nice to know you’re looking into it !
                      Don’t go the complicated way though if it can be avoided then be lazy tongue
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id