We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15558
    • 108 Posts
    Hi there,


    I’m on finishing building a bilingual website and it works pretty fine - i’m using Babel and its subfolders method. However one problem remains, and I’m sorry about that but I can’t get to any solution, while I thought this wouldn’t be that difficult.

    It’s simple : I use a few chunks in my templates. Those chunks contain some strings that have to be translated... obviously. Now tell me please, how can I ask MODx to output a chunk depending on the context ?

    I thought I could use Lexicon but am I wrong if I understood that Lexicon is a back-end-only tool ? I’m asking such things because it’s not that easy for me to read english docs... sorry again

    Any help = 1000 hugs (NOT obligatory)
      Sorry for that ⇧ , I'm no dev but I wanna try
      • 26016
      • 561 Posts
      Hi,
      An interesting question! I’m sure I’ll run into this eventually, as I love languages.

      Here’s one idea. In your template(s), you can make good use of this extremely helpful variable:
      [[*context_key]]


      I just tested this, and it works great!

      I have the above variable nested inside a chunk. Somewhat hard to read, to be sure. This goes in my template:
      [[$[[*context_key]]thingie]]


      So if I have two contexts, "francais" and "espanol", I make 2 chunks: francaisthingie and espanolthingie.

      Then your template in a particular context will choose the right chunk, and thus the right block of text will be pulled in. There are more automated ways of doing this, I’m sure, and a coder would find some via snippets or something else. I know that some people prefer using TV’s instead of chunks. There are surely more advanced ways of doing this, but this could work.

      Hope that helps!
      Dave

        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 15558
        • 108 Posts
        omg thank you so much samba, that works perfectly ! me definitively not iz smart developer.

        now send me your address by pm and i’ll come and hug you this summer

        Thank you again !
          Sorry for that ⇧ , I'm no dev but I wanna try
          • 26016
          • 561 Posts
          Ha ha!
          Ca me plait... j’aime bien les hugs. wink

          Cheers
            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 3749
            • 24,544 Posts
            If you create a current_language context setting, you could also use:

            [[$[[++current_language]]thingie]]


            I believe Samba’s solution would be faster, though.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 29839 ☆ A M B ☆
              • 66 Posts
              Perfect solution, glad i found this thread! But i think i would like to take it a step further. Since babel gives editors easy to use translate options how do i go about making the strings inside the "thingies" available for easy translation? Can i make context related tv’s available for these strings?

              I know that my client would like to add more and more languages to the site, and i’m in need of an elegant way of implementing this.