Click to See Complete Forum and Search --> : multilanguage botton
miguel001
01-28-2003, 03:46 PM
I see often languages-bottoms which take you to the startpage, when you click on it.Then the user has to browse again through the pages to arrive to the same page as he was in the first language.
Now I would take the challenge of programming a bottom which shows you exactly the same page in the other language.
The site will be databased. I will have pages like e.g.:
www.multilanguagebottom.com/index.php?ID=1
the bottom should open:
www.multilanguagebottom.com/index_f.php?ID=1
( _f for french)
If anybody sees a way to solve it, I'm looking forward for an answer.
Miguel
Webskater
01-28-2003, 04:23 PM
Is this a javascript question?
I have done a multi-language site before and it nearly drove me mad. For what it's worth the only way I found it could be managed was to put everything in the database. Page titles, column headings, help text - everything. Each page was basically an empty html template and everything was loaded in from the db. Changing languages on the fly was simple but why would you want to? Most people will choose a language at the beginning and then stick with it. If you do change horses mid-stream, as it were, you have to be careful with variables and make sure that as far as possible all parameters are numbers. Good luck.
miguel001
01-29-2003, 03:23 PM
Thanks Webskater!
The homepage is for a bilingual city in switzerland. People likes to switch on the fly between french and german.That's why they don't want to fall back to the entrance page.
The following script works fine. The only situation I'm stuck is:
If the page is opened by a selectbox, which was generated by the db, it doesn't send the location.search of the url to the page. In consecuence the script can't open the french double
instead of index.php?ID=1 the selctbox opens the right site but on the url it shows only index.php.
How could I work this around?
<script type="text/javascript">
<!--
var x =location.href;
var aufgeteilt = x.split(".");
var n = aufgeteilt.length;
for (var i=0; i<n; i++)
{
document.write("<br>");
document.write(aufgeteilt[i]);
}
var a = aufgeteilt[0]; //gives http://www
var b = aufgeteilt[1]; // gives the name
var c = aufgeteilt[2]; // gives com/folder/file
var d = aufgeteilt[3]; // gives html oder php
var e = "_f"; // the addition for the other language
var f = "."; // the dot to put between the arrays
var neue_url=a.concat(f,b,f,c,e,f,d);
document.write("<br>");
document.write(neue_url);
function aufruf()
{
self.location.href = neue_url;
}
// -->
</script>
************
the bottom to link the new page
<a href="#" onclick="aufruf()">french</a>
Webskater
01-30-2003, 06:04 AM
var neue_url=a.concat(f,b,f,c,e,f,d);
I am fairly sure that the fact you have used "var" to declare this variable means it is not visible to your function. If you just say:
neue_url=a.concat(f,b,f,c,e,f,d);
your function should see it. I think.
Charles
01-30-2003, 06:21 AM
Be careful though, relying upon client side JavaScript for navigation creates a huge barrier to accessibility. You will need to check the accessibility laws for Switzerland and the cantons involved to see to what extent your page is covered. Of course, if you are not required to make your page accessible it is still a minimally decent thing to do.
miguel001
01-30-2003, 09:52 AM
thank you webskater and Charles for contributing to find a good solution.
Now it works; even with var neue_url;
I don't know why it did not work before. Maybe the page was still in the cache.
The next step is the back-bottom which has to take away the"_f". But I think there I will go trough too.
Charles, you want to say that it would be better to generate the language-change on the server?
The solution which Webskater explained, putting all content in the database is very time-expensive.
I choosed Java-Script because otherwise I would have to make all the pages .php-pages, even for pages with html-content. The accessibility laws in switzerland are not prohibiting javascript navigation.
How would you realize it, Charles?