We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6841
    • 61 Posts
    I am building a site in Spanish, and I am thinking that the best way to make sure all my dates, times, etc. get rendered correctly is to have a plugin that listens for an event such as OnWebPagePreRender (or whatever that event is called) and then uses PHP’s setlocale() function to switch the locale setting to Spanish.

    My question is, if I want to make this more configurable so that it could be used to set the locale to any desired setting, how would I go about this? I see that you can set up some sort of configuration string for a plugin. What’s that all about? Would that help me do what I want? Also could I set it up some how so that it set the locale to Spanish at the beginning of the page rendering process and then set it back to English after the page is rendered?

    Or is there a better way to do this than using a plugin? I can’t find any documentation on how plugins work except for a few examples with no explanation.
      Dave
      • 6726
      • 7,075 Posts
      Guillaume has worked a lot on this issues, I suggest you read this :
      Add SetLocale to language files

      and this

      [Snippet] FormatDate

      Hope it helps grin
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 6841
        • 61 Posts
        Quote from: davidm at Apr 06, 2006, 09:30 AM

        Guillaume has worked a lot on this issues, I suggest you read this :
        Add SetLocale to language files

        and this

        [Snippet] FormatDate

        Hope it helps grin
        Thanks. This is useful to know it’s being discussed. However, it doesn’t really sound like the issue has been resolved.

        The FormatDate snippet doesn’t really help because the big issue is the locale setting. If my locale setting is set for English, the month names are always going to appear as January, February, etc. no matter what type of formatting string I apply (unless I use digits for the months instead of names, but I really would rather not do that).

        Aside from the locale issue, I’d appreciate any insight into the plugin configuration string--what it is, how it’s used, etc. Thanks. I’m learning slowly but surely.
          Dave
          • 33175
          • 711 Posts
          FormatDate permits to format date with the localization used. To modify your setting you can see Add SetLocale to language files. If spanish settings is not avalaibled a solution is to replace each english word by spanish word.
          If you can’t modify local setting you can use the plugin WordsReplace to replace english words by spanish words.
            Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !