We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32241
    • 1,495 Posts
    Quote from: davidm at Mar 01, 2006, 11:14 AM

    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

    Not really laugh

    I usually sleep 6 hours a day, and spent most of my times in front of comp, so you know, the life of geek :’(
    The only problem David, I have so many great ideas that I ended up not finishing up all of them. Same with MODx I believe, I created a lot of nice stuff, but ended up unable to maintain and improve it >:(

    Hope we can get more coder that are willing to help me out on this thing grin
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
      • 6841
      • 61 Posts
      Quote from: Djamoer at Mar 01, 2006, 05:19 AM

      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?
      So, where do we stand on this issue? One thing to consider if we’re going to take the approach doing our own thing rather than using setlocale() is month names.

      Personally, my main interest in locale settings is for date formatting, and one of the things provided by setlocale() is locale-appropriate versions of the month names. For example, if my locale is set for U.S. English, the date format "%e %B %Y" results in a string such as "23 March 2006". If, however, my locale is set for Spanish, that same date format results in "23 marzo 2006".

      I’m all for a solution that’s better than setlocale() because of the MySQL issues, but whatever the final solution turns out to be, it needs to accout for the issue of month names as well as simple formatting characters like decimal points, etc.
        Dave
        • 32241
        • 1,495 Posts
        If we want to implement a good multi lingual support for date and currency format, I think it’s better to have a set of standard to store date time, currency, and etc. Everytime this thing being outputed to the screen, there is always a function to be used to format this date into the right format. With this we are not being limited with some of the limitation in setLocale.
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 6841
          • 61 Posts
          Quote from: Djamoer at Apr 08, 2006, 02:37 AM

          If we want to implement a good multi lingual support for date and currency format, I think it’s better to have a set of standard to store date time, currency, and etc. Everytime this thing being outputed to the screen, there is always a function to be used to format this date into the right format. With this we are not being limited with some of the limitation in setLocale.
          I agree. I would think that we would want to store all relevant data (decimal point character, month names, etc.) in the language files. Then there could be some core functions like $modx->formatDate() to format dates and times and $modx->formatNumber() that would format them using the formatting values from the language file (or default to standard English values). The formatDate() function should probably accept a UNIX timestamp and a formatting string just like PHP’s strftime() function. These functions could be wrapped in snippets for those who wanted to use them sporadically throughout their site without having every date/time or number converted.

          Then, the next level of language support (for those who need site-wide language formatting of dates/times and numbers) would be an option in the Manager to specify a language setting (separate settings for manager and front-end) and fix the core so that any standard MODx document variables or core functions that output dates/times or numbers read these settings and use these new formatting functions to output the date/time or number in the correct format to match the setting so that the person building the site doesn’t have to worry about converting the output of all of these items.

          And then the ultimate in flexibility would be to make it so that you could specify in the manager which elements of language support you want to use. In other words, maybe, for some reason I want the front-end of my site to use Spanish output for dates/times, numbers, etc. but I want my manager UI to use German text strings but leave the dates/times and numbers in the default English format. I’m not sure how often this would be used, but it never hurts to build in flexibility from the start because someone always end up asking for it later on smiley
            Dave
            • 32241
            • 1,495 Posts
            Thanks for the input. I believe this can be valuable discussion to help our core coder make a better code based in the next overhauled of the core.

            For now, we still need to do a little hacking and patching to come up with a workaround wink
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 33175
              • 711 Posts
              Quote from: ddecjc at Apr 08, 2006, 08:28 AM

              Then there could be some core functions like $modx->formatDate() to format dates
              I have ask for this few days ago. rtrash (if I don’t mistake) is ok to do this. To format date with internationnalisation you can use the snippet FormatDate while waiting a core function.
                Sorry for my english. I&#39;m french... My dictionary is near me, but it&#39;s only a dictionary !
                • 17798
                • 1 Posts
                I know this is an old thread but after messing with setlocale a bit, I found a working solution smiley

                Quote from: Djamoer at Mar 01, 2006, 05:19 AM

                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
                To avoid SQL problems, simply use this instead:

                setlocale(LC_TIME,"pl.UTF-8");


                Note I’ve used LC_TIME (which makes the change apply to date formatting with strftime() only) and added UTF-8 for proper character encoding (make sure you’re using the same encoding as set in your site configuration). Adding this to my config.inc.php worked like a charm smiley