Click to See Complete Forum and Search --> : English/French versions of a page


Austin-qc
08-07-2003, 11:49 PM
I have a bilingual website (English/French) that has a huge number of pages.

The French and the English versions of a given page have always the same syntax except that the French version adds a /fr/ after the domain's name and a '_fr' at the end of the file's name .

For example, if an English page is located at:
http://www.mydomain.com/firstpage.html

The French version of that page is located at:
http://www.mydomain.com/fr/firstpage_fr.html

I would like to offer on each single page to the visitor the possibility to chose his language (to go to the corresponding page in an another language). Is there a simple script, could it be a Javascript or a combination of SSI and JS that would read the actual address and allow the visitor to go back and forth from one language to the other?

Thank you in Advance
Mel

Khalid Ali
08-08-2003, 01:43 AM
you can load a default page(say english) and have a link on that page that points to the french language page....

Austin-qc
08-08-2003, 02:46 AM
'Shoukran' Khalid.

That implies that I'll have to write the code manually (what you suggest) on 6000 pages (3000 for each language).

Since I'm using SSI (the INCLUDE command) I thought I would be able to insert the code only twice, one for each language in the included file (a menu).

Charles
08-08-2003, 05:13 AM
You can use SSI to include the outout from scripts and you can certainly use Perl to take the requsted URL and then generate the links. See http://www.perldoc.com/perl5.8.0/lib/CGI.html.

cflynn
08-08-2003, 05:47 AM
I would suggest setting a variable equal to window.location, using variable.substring to get the page the user is viewing, and then build the url for french and english versions. If you put it a function you could just link to a blank anchor and have an onClick command on the link.

Charles
08-08-2003, 06:36 AM
Originally posted by cflynn
I would suggest setting a variable equal to window.location, using variable.substring to get the page the user is viewing, and then build the url for french and english versions. If you put it a function you could just link to a blank anchor and have an onClick command on the link. And then it will not work for the 13% of users who do not use JavaScript. My suggestion, if you can get to work at all, will work for all users.

Austin-qc
08-08-2003, 11:02 PM
Forgot to mention: It is an Intranet. So the JavaScript solution would be the best I guess.

cflynn
08-09-2003, 12:38 AM
so here's some code that might help you out:

function chgLan(lan) { //where lan is either 'english' or 'french'
var domain='http://www.mydomain.com/'; //your domain goes here
var domLen=domain.length;
var current=window.location(); //where frameName is the name of the content frame
var len=current.length; //get the length of location
var isFr=current.substring(domLen,(domLen+1)); //check if the characters immediately after your domain are 'fr'
if (isFr=='fr') { //strip all that off and return only the page name
var page=current.substring((domLen+3),(len-8));
var frPage=domain + page + '.html';
} else { //if not add that add them
var page=current.substring(domLen,(len-5));
var engPage=domain + 'fr/' + page + '_fr.html';
}
if (lan='french') {
swtpage=frPage;
} else {
swtpage=engPage;
}
window.location()=swtPage;
}

and in you link:

<a href="#" onclick="chgLan('english');">English Verson</a>

Do another link for the french version.

Hope this helps.

Austin-qc
08-09-2003, 12:49 AM
Thanks a zillion cflynn. I will try it and come back to you on this.