We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Moderator note: This topic was split off from the Snippet Optimization Thread found here.

    The best is used core function to manage charset in the same time : strftime() return dates in ISO-8859-1. A substitution of croe function (while waiting it) is my snippet FormatDate

    Is this true even if you’ve changed the default charset in the Manager/System configuration?
      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
      • 33175
      • 711 Posts
      I have just found a note mislaid on my desk:

      Use language files for all messages (errors, success, bad configuration) instead of string in code
      if ($bError) echo 'An error occured.'; // bad
      

      // default language file
      include_once('language/files/path/enfile.php'); // good
      // second language file
      include_once('language/files/path/frfile.php'); // good
      
      // if error display the error message
      //     if string is not into the second laguage file, the string is found in the primary
      if ($bError) echo $rnStrMsgErrorOccured; // good
      
        Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
        • 33175
        • 711 Posts
        @sotwell :
        Is this true even if you’ve changed the default charset in the Manager/System configuration?
        Yes. I have posts many message to resolve this problem in the french forums and english also, without result.
        After many searchs on the web, I have found that is a limitation of the PHP function date() which is not affected by setloca()l
        Moreover, strftime() is affected by this but it returns date only in ISO-8859-1. It is a very bad limitation. The solution is to use utf8_encode() to modify the charset of this date.

        See also code of my snippet FormatDate to view how I have resolve this problem.
          Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
          • 33175
          • 711 Posts
          setlocale() modifies local configuration on the server. An extract on the php documentation for parameters :
          * LC_ALL for all of the below
          * LC_COLLATE for string comparison, see strcoll()
          * LC_CTYPE for character classification and conversion, for example strtoupper()
          * LC_MONETARY for localeconv()
          * LC_NUMERIC for decimal separator (See also localeconv())
          * LC_TIME for date and time formatting with strftime()
          * LC_MESSAGES for system responses (available if PHP was compiled with libintl)

          It is very useful to adapt Modx in every language. Error strings, date, ect...
          For exemple, it permits to format date like this :
          /* Set locale to Dutch */
          setlocale(LC_ALL, 'nl_NL');
          /* Output: vrijdag 22 december 1978 */
          echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
          
          /* Set locale to English */
          setlocale(LC_ALL, 'en_EN');
          /* Output: February 22 december 1978 */
          echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
          
          /* Set locale to French */
          setlocale(LC_ALL, 'fr_FR');
          /* Output: février 22 décembre 1978 */
          echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
          


          I know it is possible to display monetary symbol but I have not tested it.
          In french, it is euro (€). In american, dollar ($).

          Many possiblities are offered but I know only a few part.

          A restriction of this function (setlocale) is that is not implemented in all PHP function (I think at date()).

          Person says to use setlocale(LC_ALL, ’fr_FR.UTF-8’) make formating with accents but I can’t make work this.
          Also, it is prefered to use utf8_encode when the PHP function return in ISO format by default.

          For localization, french community has found a tip to display correctly some values : put setlocale(LC_ALL, ’fr_FR’) on the top of the language file. With this way, I have found one problem : strftime is not affected by this. It’s for that that I use utf8_encode.

          A restriction is that the server must be compiled with the localization asked. Else, localization used is the default (in general english).

          I hope this could help you.
          Other questions ? wink
            Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
            • 33175
            • 711 Posts
            A little precision, I am a PHP developer whose worked on aplication from scratch with UTF-8, internationalization and multi-lingual content. It is a great help for me wink
              Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
            • Guillaume, any feedback or input on things we should change at the core level are tremendously appreciated. I really want MODx to be a first-class multi-language site builder.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 33175
                • 711 Posts
                Guillaume, any feedback or input on things we should change at the core level are tremendously appreciated. I really want MODx to be a first-class multi-language site builder.
                Multi-language is a very hot topic here and there are very many topics speaking abour this.
                But I have no time to spend to search for the "principal" topic. Can you indicate me please ? Thanks very much.
                  Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
                • That’s the point: real-world experience carries a lot of weight! And I can’t always take the time run the stuff through the goolge language tools in the French forums, either. wink

                  Regardless, I’ll see if I can get some assistance tracking down a few salient threads and link them here.
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • tillda’s proposal to change the way language variables are stored/accessed

                    Madmage’s multi-national manager modifications

                    Wendy’s sub-sites modification or his multi-content discussion which could be used to generate language-specific sites based on different root folders in the top level of the manager.
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 32241
                      • 1,495 Posts
                      Quote from: rthrash at Mar 14, 2006, 02:07 PM

                      tilla’s proposal to change the way language variables are stored/accessed

                      Madmage’s multi-national manager modifications

                      lol, the first one will be for madmage, and the second one is the idea from tilla tillda wink
                        Wendy Novianto
                        [font=Verdana]PT DJAMOER Technology Media
                        [font=Verdana]Xituz Media