Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 1st, 2003, 08:03 AM
Registered User
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi language web pages

How do I create a web page that will display in one of two languages;
1) dependent on a users browser setting
2) manually change display language by clicking a button

Old September 18th, 2003, 07:45 PM
Registered User
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chadlupkes Send a message via Yahoo to chadlupkes

I'm surprised this has been in the que for this long without a reply. I'm just starting, but there should be a way to use an if statement to either load different html files depending on language preference, or even within the body of the original page. Then an onclick() function could be placed on a set of links or flag graphics to change the language on the fly; basically the page would reload with the new language text.

Does that help?

Chad Lupkes
Old October 12th, 2003, 05:19 PM
Authorized User
Join Date: Aug 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts

you have two different ways of doing it.
- Having the files existing in both languages in two different directories ( /en , /de , /fr ... )
- using the same html templates with dynamic text depending on the language.
In the second case ( which is best, because you can create easily a new language ), you should use a serverside script language, like php, and the easiest way would be to use a dictionnary file (the other way would need a database).
For example, if you have two files :
- fr.dictionnary.php (french) :
    $hello = "bonjour";
    $enter = "Veuillez entrer";
- en.dictionnary.php (english)
    $hello = "hello";
    $enter = "Please enter";

In your main file, when you know the language of the user (with javascript on the browser, or with a form ), you can map it in the codes for the languages you provide (don't forget to put one language by default).
let's say you have now a var called $lng that is equal to "fr";
in your main file :

<? include $lng.".dictionnary.php"; ?>
<? echo $hello; ?><br />
<a href="inside.html"><? echo $enter; ?></a>

This will display in french.

hope that'll help.

php/java developer
NTIC engineer

Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt multi language RoeZ XSLT 2 October 26th, 2007 06:50 AM
Multi-language website: almost there electricspace ASP.NET 2.0 Basics 0 July 28th, 2007 06:21 PM
Multi language web site asifqua Classic ASP Databases 9 December 5th, 2006 04:34 AM
Multi-language Lofa ASP.NET 1.0 and 1.1 Basics 2 October 25th, 2005 04:10 AM
Multi-Language version Gjerstad BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 18th, 2003 05:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.