We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4673
    • 577 Posts
    OK, I hope that I got your attention.

    I’ve seen lots of great snippets/plugins being produced but each time I cringe a little since I see language usage hard coded into the snippet. I wanted to post a red flag on this because if we keep going down this road at this speed (YES, I am very thankful for each new bit of contributed code!!!) I’m really worried that later on we’ll be stuck with lot’s of cleanup being needed for translations and such.

    I was thinking that we should sort of come up with an intern solution or better yet a pre-final agreement on at least 1-2 (3) ways to approach taking care of not allowing straight wordings in code. (// comments should be the exception of course!)

    I mentioned 1-3 solutions that way we can at least try to conform to some type of standard and then later down the road narrow it down to one approach that was being discussed in another thread.

    Oh well, this is just a simple opinion from a simple minded person grin
      Tangent-Warrior smiley
    • That’s a great idea Carsten... now I’ll leave it up to you code-minded and multi-lingual folks to start the discussion!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • I’m already including a "langs" folder in my snippet folder (assets/snippets/mysnippet/langs), with a basic lang.php file that has an array of variables for replacing all of the text strings displayed by the snippet. Of course, for me, it’s in English, but it would be easy enough to translate it.

        I use some form of the snippet name (such as $_docman[’whatever’] = "Whatever"; for the document manager snippet) to keep things organized. The snippet looks for a "lang" variable (I’m using cookies for language session management for multilanguage sites, it could be stored in the SESSION variable, but that requires hacking the login/logout snippet, or the URL, which also requires some hacking of various scripts, including all menu snippets), or it just uses the lang.php file as default.

        It’s pretty simplistic, I know, but it works.
          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