/    Sign up×
Community /Pin to ProfileBookmark

multilanguage botton

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.:
[url]www.multilanguagebottom.com/index.php?ID=1[/url]

the bottom should open:
[url]www.multilanguagebottom.com/index_f.php?ID=1[/url]
( _f for french)

If anybody sees a way to solve it, I’m looking forward for an answer.

Miguel

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@WebskaterJan 28.2003 — 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.
Copy linkTweet thisAlerts:
@miguel001authorJan 29.2003 — 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>
Copy linkTweet thisAlerts:
@WebskaterJan 30.2003 — 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.
Copy linkTweet thisAlerts:
@CharlesJan 30.2003 — [font=georgia]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.[/font]
Copy linkTweet thisAlerts:
@miguel001authorJan 30.2003 — 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?
×

Success!

Help @miguel001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...