Multilingual/Multidomain

How can I create a multilingual site?

  • For every langauge we need an own category tree.
  • Every language has its own template with links (switches) to the other language tree.
  • The navigation simply begins at the first ID of the language root category.


Version: V1.2.7 - 1.x.x

Forum: http://forum.phpwcms.org/viewtopic.php?p=83791#p83791

Basics: Level and IDs for a multilingual site

An example using the two languages english [en] and german [de] (IDs are coincidentally selected).

 ------------------------------------
L  E  V  E  L
-:  :  :  :  :
-0  1  2  3  4   <- LEVEL-No.)
-:  :  :  :  :
-+ home   :  :                        ID=0
-+--+ en                              ID=01
-+--+--+ en_category_01               ID=02
-+--+--+ en_category_02               ID=03
-+--+--+--+ en_category_02_01         ID=05
-+--+--+--+--+ en_category_02_01_01   ID=07
-+--+--+--+--+ en_category_02_01_02   ID=08
-+--+--+--+ en_category_02_02         ID=06
-+--+--+--+ en_category_02_03         ID=09
-+--+--+ en_category_03               ID=04
-+--+--+ en_category_04               ID=10
-:  :  :  :  :
-+--+ de                              ID=11
-+--+--+ de_Kategorie_01              ID=12
-+--+--+ de_Kategorie_02              ID=13
-+--+--+--+ de_Kategorie_02_01        ID=15
-+--+--+--+--+ de_Kategorie_02_01_01  ID=17
-+--+--+--+--+ de_Kategorie_02_01_02  ID=18
-+--+--+--+ de_Kategorie_02_03        ID=16
-+--+--+--+ de_Kategorie_02_03        ID=19
-+--+--+ de_Kategorie_03              ID=14
-+--+--+ de_Kategorie_04              ID=20

category
-:  :  :  :  :
-0  1  2  3  4   <- LEVEL No.
------------------------------------

Level based: The level is relatively addressed by using a divided navigation, (e.g. horizontal and vertical). More see “Level-Lift” at the bottom.

Every language [en] & [de] has its own category trees (ADMIN → site structure).

And every language [en] & [de] has its own template.

Please create the templates first :!:


It turned out as meaningful to finish the side in one language and then copy then the complete language tree for the use of other languages. Afterwards the languagespecific category title and alias name are given to the copied categories.

Template: Language switch

We need two links in every template for a switch to the other language.

Simple version:

<!-- ===== Language-Switch [en] //-->
<div id="language_switch">
  <a href="index.php?de" target="_self">Switch to german</a> | english active
</div>
<!-- ===== End Language-Switch //-->
<!-- ===== Language-Switch [de] //-->
<div id="language_switch">
  Deutsch aktiv | <a href="index.php?en" target="_self">umschalten nach Englisch</a>
</div>
<!-- ===== End Language-Switch //-->


In this example I use little flag images 23x15px (CSS inserted).

In your [en] template please insert e.g.:

language switch [en]

<!-- ===== Language switch //-->
<div id="language_switch">
  <div id="flag_de">
    <a href="index.php?de" target="_self"><img src="img/leer.gif" border="0" vspace="0" hspace="0" alt="german" width="23" height="15" title="switch to german" /></a>
  </div>
  <div id="flag_en_act">
    <a href="index.php?en" target="_self"><img src="img/leer.gif" border="0" vspace="0" hspace="0" alt="english" width="23" height="15" title="enlish active" /></a>
  </div>
</div>
<!-- ===== End Language switch [en] //-->

In your [de] template please insert e.g.:

language switch [de]

<!-- ===== Language switch [de] //-->
<div id="language_switch">
  <div id="flag_de_act">
    <a href="index.php?de" target="_self"><img src="img/leer.gif" border="0" vspace="0" hspace="0" alt="deutsch" width="23" height="15" title="Deutsch aktiv" /></a>
  </div>
  <div id="flag_en">
    <a href="index.php?en" target="_self"><img src="img/leer.gif" border="0" vspace="0" hspace="0" alt="englisch" width="23" height="15" title="umschalten nach Englisch" /></a>
  </div>
</div>
<!-- ===== End Language switch [de] //-->

NAVIGATION

A simple verticle navigation at the right/left using the navigation tag {NAV_LIST_UL:F ……..

  • en: {NAV_LIST_UL:F,01,,act_path,active,,,}
  • de: {NAV_LIST_UL:F,11,,act_path,active,,,}


Combination of an horizontal & vertical navigation

E.g. The horizontal output

+---------------------------------------------------------------------+
| [en_category_01] [en_category_02] [en_category_03] [en_category_04] |
+---------------------------------------------------------------------+
en: <div class="nlu_horiz1">{NAV_LIST_UL:F,01,1,act_path,active}</div>
de: <div class="nlu_horiz1">{NAV_LIST_UL:F,11,1,act_path,active}</div>

(one level deep).

E.g. the vertical sub output for an active en_category_02 using the Level-Lift.

[en_category_01] [en_category_02] [en_category_03] [en_category_04]

+----------------------+
| [en_category_02_01]  |
| [en_category_02_02]  |
| [en_category_02_03]  |
+----------------------+


Please copy this snippet into every language template. You can lift an ID based navigation to an level based navigation.
I called it Level-Lift. (Have a look too - NAV_LIST_UL (CSS) at the end.

[PHP]
if(isset($GLOBALS['LEVEL_ID'][1])) {
  $level_id = $GLOBALS['LEVEL_ID'][1];
  echo '<div class="nlu_navi1">'.LF;
  echo '{NAV_LIST_UL:F,'.$level_id.',,act_path,active,,,}';
  echo '</div>';
  }
[/PHP]

Where LEVEL_ID'[X] is the level.


Switch for Different domains

You only need this switch if every language has its own domain. :!:

Forum: http://www.phpwcms.de/forum/viewtopic.php?p=73725#73725

There is a switch working with two domains mydomain1.com and mydomain2.com generating an HTTP Status Code:
HTTP Status Code: HTTP/1.1 301 Moved Permanently

Please use only this entry in config:

$phpwcms['site'] = 'http://'.$_SERVER['SERVER_NAME'].'/';


$_SERVER['SERVER_NAME'] should always contain the current called Domain.

Copy this snippet into the folder include/inc_script/frontend_init/

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_init'] = 1;


Your Domains- and starting alias names you must be registered in the script.
(A short version of this script you will find in: /template/inc_Script/frontend_init/disabled/domaincheck.php).

rt_domainswitch.php

<?php
// compare against current domain and redirect to correct if neccessary
// http://www.phpwcms.de/forum/viewtopic.php?p=73771
// Installation: Put this snippet into the folder /frontend_init/
// and switch at conf.inc.php: $phpwcms['allow_ext_init']    = 1;
// E.g.:
// Startpoint from mydomain1.com is the ID=01 -> $LEVEL_ID[1] = 1
// Startpoint from mydomain2.com is the ID=11 -> $LEVEL_ID[1] = 11
//
// PHPWCMS_URL -> http://mydomainX.com/
// returnGlobalGET_QueryString() -> ?alias
// $aktion[0] == 0 -> pointer at the root level
 
 
if(isset($LEVEL_ID[1])) {
   // Pointer behind the root level ?
   // Yes -> check active Domain behind root level
      if($LEVEL_ID[1] == 1 && strpos(PHPWCMS_URL, 'mydomain1.com') === false) {
      // E.g. Using the ID=1 (for maydomain1.com) but with the domain maydomain2.com, than switch back to .mydomain1.com
      // E.g. http://www.mydomain2.com/index.php?1-contact  switch to http://www..mydomain1.com/index.php?1-contact
         headerRedirect('http://www.mydomain1.com/index.php'.returnGlobalGET_QueryString());
      } else {
       // The same for the domain mydomain2.com
         if($LEVEL_ID[1] == 11 && strpos(PHPWCMS_URL, 'mydomain2.com') === false) {
            headerRedirect('http://www.mydomain2.com/index.php'.returnGlobalGET_QueryString());
            }
         }
} else {
   // check root level for active Domain
   if($aktion[0] == 0) {
   // pointer on the root level e.g. http://mydomain1.com/  ??
      if(strpos(PHPWCMS_URL, 'mydomain1.com')) {
      // Yes, go to my startpage for the domain 1
         header( "HTTP/1.1 301 Moved Permanently" );
         headerRedirect('http:/www.mydomain1.com/index.php?mydomain1_start');
      } elseif(strpos(PHPWCMS_URL, 'mydomain2.com')) {
         // The same for domain 2
         header( "HTTP/1.1 301 Moved Permanently" );
         headerRedirect('http://www.mydomain2.com/index.php?mydomain2_start');
         } else {
         //redirect to "default"  -> Fallback if there is an third domain or what ever
            header( "HTTP/1.1 301 Moved Permanently" );
            headerRedirect('http://www.default.com/index.php?default_start');
            }
      }
}
?>
english/phpwcms-system/admin/site-structure/multilingual.txt · Last modified: 2009/10/24 13:23 by Knut Heermann (flip-flop)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0