We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38660
    • 7 Posts
    After working on the problem explained below for two days, I found the solution so far just after posting here:
    The "subfolders" have to have the same name like the culture key, e.g.: base_url has to be "en" for the culture key "en" and not "com", what I did.
    O.k. one step further in learning modx.

    Hi,
    I am trying to add a second language version to a Website via a second context, how it is discribed in the nice tutorial by "Design from Within"

    On a localhost installation I managed to get it working, but on a www server it does not work.
    Default language: de, context: web
    Second language: en, context: English

    The problem is, that the switch via the gateway-plugin accordingly to the cultureKey set in the context settings does not work, it always switches/stays at the default context "web". When I change the default context in the gateway to English, it is switching there.

    My setting of the context "English": see attached image.

    my Gateway plugin:

    <?php
    if($modx->context->get('key') != "mgr"){
      /* grab the current langauge from the cultureKey request var */
        switch ($_REQUEST['cultureKey']) {
          case 'en':
          /* switch the context */
          $modx->switchContext('English');
          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']);
      }
    


    And the changed part of the .htaccess:

    # 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 ^(de|en)/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 ^(de|en)/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 ^(de|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
    


    PHP Version 5.2.12-nmm4
    Apache 2.0 Handler
    MySQL Version 5.1.63-nmm1-log
    MODx Revolution 2.2.0-pl2 (traditional)
    MacOS 10.6.8
    Safari 5.0.5

    Any help is appreciated,

    [ed. note: panophoto_hh last edited this post 14 years, 3 months ago.]