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

    I would like to make some change on Babel. It install and it works.

    I have the two word "Francais" and "English" to go to a language and to another.
    I did not find the ways to have the flag instead of the letter.

    Second question, if for example I did not translate the page "Presentation" (I only have the french version). How can I do in order to make sure that the english flag is not displayed. The visitor will see only the french flag?

    Many thank for your help
      • 33277
      • 35 Posts
      Hey there.

      I'm not a real MODx expert, but I'm using Babel myself and that's what I can suggest. It should be easy.
      The key is the &tpl parameter of BabelLinks snippet. It's the chunk you want it to use to display the language link with.

      So,

      • Create a chunk, say 'babel-links-as-img'
      • Fill it with this or similar:
      <a href="[[+url]]"><img alt="Switch language" src="/assets/flag-[[+cultureKey]].png" /></a>

      • Add the &tpl=`babe-links-as-img` (or whatever you named the corresponding chunk) to your BabelLinks call
      • Put the flags with the name /assets/flag-en.png and /assets/flag-fr.png (or what you have defined in the chunk

      It should work, despite I didn't try this myself still (but I will need too).

      Feel free to ask any questions. [ed. note: yurkobb last edited this post 12 years, 1 month ago.]
        <em>The Earth is not the hell, and people aren't cursed, and joy in not a sin, but a gift of God.</em> (Lesia Ukrainka)
        • 34901
        • 3 Posts
        Hi,

        yes it works perfectly:)

        In my case I simply add the following code line to display horizontally 3 language flags (nl - en - fr)in my footer:

        [[BabelLinks? &tpl=`babel-links-as-img`]] 


        I also customized a bit the "babel-links-as-img" chunk to fit my requirements like this :
         <a href="[[+url]]"><img alt="Switch language" src="assets/templates/house/images/flag-[[+cultureKey]].png" />  </a>


        Enjoy!
          • 39982
          • 28 Posts
          Hello,

          I am working locally with couple of different language site and using Babel with country flags "babel-links-as-img"
          <a href="[[+url]]"><img src="site/assets/flags/flag-[[+cultureKey]].gif" /></a>


          and added following in one chunk which is used in the whole site.
          <p>[[BabelLinks? &tpl=`babel-links-as-img`]]</p> 


          I made different context for each language, and needed to link every country flag to right context [[~id]]. How could I do that? Default "web" language is english.

          Whole site is using only one template.

          .htaccess file is modified
          # The Friendly URLs part
          
          # redirect all requests to /de/favicon.ico and /nl/favicon.ico
          # to /favicon.ico
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^(en|se|de|nl|es)/favicon.ico$ favicon.ico [L,QSA]
             
          # redirect all requests to /de/assets* and /nl/assets* to /assets*
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^(en|se|de|nl|es)/assets(.*)$ assets$2 [L,QSA]
            
          # redirect all other requests to /de/* and /nl/*
          # to index.php and set the cultureKey parameter
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(en|fi|se|de|nl|es)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]


          gateway plugin is also made
          <?php
          if($modx->context->get('key') != "mgr"){
                          /* grab the current langauge from the cultureKey request var */
                          switch ($_REQUEST['cultureKey']) {
          		    case 'se':
                                  /* switch the context */
                                  $modx->switchContext('se');
                                  break;
          		    case 'de':
                                  /* switch the context */
                                  $modx->switchContext('de');
                                  break;
          		    case 'nl':
                                  /* switch the context */
                                  $modx->switchContext('nl');
                                  break;
                              case 'es':
                                  /* switch the context */
                                  $modx->switchContext('es');
                                  break;
                              default:
                                  /* Set the default context here */
                                  $modx->switchContext('web');
                                  break;
                          }
                          /* unset GET var to avoid
                           * appending cultureKey=xy to URLs by other components */
                          unset($_GET['cultureKey']);
                      }


          Many thank you for your help,
          Tom
            • 39982
            • 28 Posts
            Hello,

            I solved the problem with Babel. I did all with fresh install and now Babel works fine.

            Thanks,
            Tom
              • 47348
              • 1 Posts
              Hi,

              How to list the Babel using <select><option> instead using <ul><li> style?

              please help! Thanks