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

    There exist a way to translate the same TV checkbox values according context change?

    For example, i´m using Babel to my multilingue website, and in my tranlated template i´m using a checkbox Tv with some values, ex:

    Air conditioning||Automatic irrigation||BBQ...


    My question is, can i use the same checkbox TV and have it dynamically translated? I hope there exist a way to do this... because i wan also preserve the checked values under the tranlation...

    Sorry about my english

    This question has been answered by bertoost. See the first response.

    [ed. note: legues last edited this post 12 years, 11 months ago.]
      • 16899
      • 284 Posts
      Hi guys

      Any idea about this? All i want to do is get a way to translate TV input values! Does anybody had this problem?

      Many thanks in advance!!!!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
          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
          • 16899
          • 284 Posts
          Hi Sottwell

          First off all thanks a lot to help me on this!!!! smiley
          Nice idea!!! I didn´t know nothing about this!!! Can you explain me better how can i use the situation in a TV type checkbox?

          Many thanks
          Nuno
            • 41592 ☆ A M B ☆
            • 83 Posts
            you can put your TV value in your Lexicon tag like:
            [[%yournamespace.[[*yourTvValueAsLexiconKey]]? &namespace=`` &topic=`yourTopic` &cultureKey=`[[++cultureKey]]`]]
            

            where "yourTvValueAsLexiconKey" is your TV Value.

            Then you make a new entry in your Lexicon Panel, one for every language you need to translate.

            Lexicon search for its values ​​to the corresponding one.
            &language=`` is used to define which language withdraw this value.
            [[++cultureKey]] is a system setting that grab default front-end language

            Babel allow you to define your cultureKey for every context laugh [ed. note: solidusite last edited this post 12 years, 11 months ago.]
              Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
            • discuss.answer
              • 3186 ☆ A M B ☆
              • 279 Posts
              Does this work in the backend?? I guess the [[% ... ]] solutions only work on the frontend. When I'm wrong;

              I suggest to use a input value like;

              Air conditioning==airco||Automatic irrigation==autoirri||BBQ==bbq ....

              Or something.. This will make the actual value "airco" or "autoirri" or anything else, and will make your front-end loading of translations much easier. Just create lexicon entries with the right namespace and key and put your TVs' value in it as described before.

              What I always do in multi-language cases;

              1. create namespace "site", with core path "{core_path}components/site/"
              2. create folders/file structure like: core/components/site/lexicon/en/default.inc.php
              3. put this content in the PHP file;

              <?php
              
              $_lang['site.your_lexicon_key'] = "Your lexicon value";

              // and duplicate, rename key for more keys

              4. Make it load automatically on all frontend pages with a "OnHandleRequest" plugin like this;

              <?php
              
              if($modx->context->get('key') == 'mgr' || $modx->event->name != 'OnHandleRequest') { return ''; }
              
              $modx->lexicon->load('site:default');


              5. Now you can simply use [[%site.your_lexicon_key]] without those parameters.

              Because you're using Babel, I guess it's unnecessary to say that you should set "cultureKey" to every context.

              Hope this helps.
                MODX Ambassador (NL) & Professional MODX developer
                Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                MODX e-commerce solution SimpleCart
                • 16899
                • 284 Posts
                Quote from: bertoost at Oct 15, 2013, 04:02 PM
                Does this work in the backend?? I guess the [[% ... ]] solutions only work on the frontend. When I'm wrong;

                I suggest to use a input value like;

                Air conditioning==airco||Automatic irrigation==autoirri||BBQ==bbq ....

                Or something.. This will make the actual value "airco" or "autoirri" or anything else, and will make your front-end loading of translations much easier. Just create lexicon entries with the right namespace and key and put your TVs' value in it as described before.

                What I always do in multi-language cases;

                1. create namespace "site", with core path "{core_path}components/site/"
                2. create folders/file structure like: core/components/site/lexicon/en/default.inc.php
                3. put this content in the PHP file;

                <!--?php
                
                $_lang['site.your_lexicon_key'] = "Your lexicon value";

                // and duplicate, rename key for more keys

                4. Make it load automatically on all frontend pages with a "OnHandleRequest" plugin like this;

                <?php
                
                if($modx--->context->get('key') == 'mgr' || $modx->event->name != 'OnHandleRequest') { return ''; }
                
                $modx->lexicon->load('site:default');


                5. Now you can simply use [[%site.your_lexicon_key]] without those parameters.

                Because you're using Babel, I guess it's unnecessary to say that you should set "cultureKey" to every context.

                Hope this helps.

                I tried this solution and it work like a charm! But i just need to create the plugin part... it makes all the sense!!! I think this is a chapter that the MODX team should explain to all the "green" Modxers... in my opinion it´s really important in a multilingual website development!!!

                I guess from now, i´ll create always a custom lexicon entry in my websites. It males all the sense.

                Thanks a lot to all the people who helped me with this situation!!! smiley
                  • 45794
                  • 2 Posts
                  You can also try this translation platform: https://poeditor.com/.
                    • 45794
                    • 2 Posts
                    You can also try this translation platform: https://poeditor.com/.
                      • 47243
                      • 30 Posts
                      Hi!
                      Guys, I'd love to know exactly how you manage to get the translation of of a multiselect listbox TV.
                      Nevertheless I found a solution which doesn't seem nice but works.
                      Here it is

                      So I created a namespace for my website and then 2 entries with the same name: "myTVContent" (one for "en" and the other for "fr")
                      At first I just then put [[!%myTVContent? &namespace=`myNamespace` &topic=`default`]] in the input value for the multiselect listbox TV

                      but it wouldn't process my lexicon , so I use @EVAL like this:
                      @EVAL $modx->lexicon->load('myNamespace:default');return $modx->lexicon('myTVContent');

                      would like to know what you think about this solution.
                      Now if I want to add new categories, I will have to add it at the end and be careful that both translation have similar elements separated by ||.

                      regards