We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36931
    • 206 Posts
    Dear All,
    I would like to request your assiatnce in order to fix an issue with babel.
    I ma trying to setup a multilanguage web site (fr, en). Its URL is temporarely:
    http://www.mywebsite.com/modx/
    (later I will move it to the root)

    Could let me what I did wrong.

    1) I created a contact call "en" and I added 4 new parameters
    - key: basel_url, name: Base URL, value :/modx/, lexique: language
    - key: cultureKey, name Culture key, value : en, lexique : language
    - key : site_start, name : Site start, value : 13, lexique : language
    - key: site_url, name : Site URL, value : http://www.mywebsite.com/modx/en/

    2) I modifed the web context and added 4 parameters
    - key: basel_url, name: Base URL, value :/modx/, lexique: language
    - key: cultureKey, name Culture key, value : fr, lexique : language
    - key : site_start, name : Site start, value : 1, lexique : language
    - key: site_url, name : Site URL, value : http://www.mywebsite.com/modx/

    3) I change the permission System->Acces list, I right click on (anonymous) and I added the "en" context with the following right:
    en - Member - 9999 - Load Only

    Finally I added into my template [[!BabelLinks]]

    My problems
    For now I can create trabslated pages, and the pages are create under the "en".
    On my web pages, I can see the language menu, but when I click on the "english" links I can not see the english menu.

    For exemple, when I click on the menu "Access media" and then I click on the english links to display the english version, the trabslated page can not be found.
    MY url is like this : http://www.mywebsite.com/modx/en/media-access.html

    I also created a plugin called "gateway" with that code
    <?php
    //make sure the plugin does not run on the mgr context (the manager)
    if ( $modx->context->get( 'key' ) != 'mgr') {
    /**
    * grab the current context from the request "c" parameter (or context_param_alias from system settings)
    * the alternative .htaccess friendly URL rewrite rule must be activated
    */
    	$cntxt_param = $modx->getOption('context_param_alias', null, 'cultureKey');
    	if ( isset( $_REQUEST[$cntxt_param] ) && $_REQUEST[$cntxt_param] != '' ) {
    		switch ( $_REQUEST[$cntxt_param] ) {
    
    			case 'fr':
    			$modx->switchContext('web');
    			break;
    
    			case 'en':
    			$modx->switchContext('en');
    			break;
    
    			default:
    			// nothing because web is default
    			break;
    		}
    	}
    }
    



    On my .htaccess file, I add this
    #BABEL
    # redirect all requests to /de/favicon.ico and /nl/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|en)/favicon.ico$ favicon.ico [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|en)/manager/templates/rives/(.*)$ manager/templates/rives/$2 [L,QSA] 
     
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|en)/images(.*)$ images$2 [L,QSA] 
    
    # redirect all requests to /de/assets* and /nl/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|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 ^(fr|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
    
    #END BABEL
    

    Do you have an idea which can help me?
    Thanl [ed. note: pierrot1010 last edited this post 14 years, 11 months ago.]
      • 36931
      • 206 Posts
      Ok I got the answer

      This gateway plugin will ne to be activated by a OnHandleRequest, to do this go to the System Events tab, scroll down to the OnHandleRequest line and enable this.
        • 39432
        • 6 Posts
        I have the same problem even after i activated OnHandleRequest on the gateway-plug.

        I have these contexts:
        - web (fr)
        - de (main-language)
        - it
        - eng

        and i created a new one (fr) and then I realised, that I'd like to keep the web-context for the french-content i deleted the fr-context. Since then only de/it/eng work and if i click on the babel-links to switch to the french-version (web-context) it displays "page can not be found" (not the specified 404-site, just a browser-message). Before everything worked (so it couldn't be the .htaccess-file) and the other languages work, the culturekey etc is set up correctly, so what could have changed/be misconfigured?

        edit:

        solved it:

        $modx->switchContext('fr'); in the gateway instead of $modx->switchContext('web');
        (...) [ed. note: tobiasweeldee last edited this post 14 years, 6 months ago.]