Mukltilingual site

garyscottadamso

New Member
i'm designing a multilingual website and for every page I design, there will be a french version. Therefore on every page, there will be a link saying ''french'' and when the user clicks it, they will be directed to the same page but in french.

so if you were on the page

X.com/en/news.html clicking "french" would direct you to
X.com/fr/news.html

note the change in the url directory from ''en" to "fr"

Is there a way in which I can make a page automatically link to a document with the same name as itself but in a different directory? i.e. the "en" directory changes to ''fr''

any ideas?
thanks
Gary
 

RenaissanceMan

New Member
This may be overkill, but Textpattern has a very good plugin for managing multilanguage sites - in the admin, there's a table showing which pieces of content have been assigned to which admin user for translation and which languages they've been translated into.

If you're creating a static site it's just a matter of including the link by hand.

If you're using PHP includes to template your site, try something like the following:

PHP:
function outputTranslatedLink {
$input = explode('/', $_SERVER['REQUEST_URI']);

/* Since $_SERVER['REQUEST_URI'] starts with /, the first array value will be empty */

if($input[1] == 'en') {
  $input[1] = 'fr';
  $lang = 'French Version';
  }
elseif($input[1] == 'fr') {
  $input[1] = 'en';
  $lang = 'Version Anglais';
  }

$output = '/' . implode('/', $input); // Add the leading slash back in

if($_SERVER['QUERY_STRING'] !='') {
  $querystring = '?' . $_SERVER['QUERY_STRING'];
  }
else {
  $querystring = '';  // no query string
  }

echo '<a href="http://' . $_SERVER['HTTP_HOST'] . $output . $querystring . '">' . $lang . '</a>';
}

Then you can call outputTranslatedLink() in each of your templates.
 
Last edited:
Top