|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using multiple languages
How can I get my web site to work with multiple languages? Examples of web sites that use this are:
http://www.debian.org http://www.gnu.org Based on what language your browser is, it views the web site in that language. Also, you can choose what language you want to view the web site in, manually (Just click on the link for that language). I will be getting some people interested, to translate. How can I accomplish this? |
|
#2
|
||||
|
||||
|
How does your page work? If its html or flash, then you will have to make a separate file for each language.
If you're using a language such as perl or php, you can set a cookie, and then depending on the value of the cookie, output different text.
__________________
|
|
#3
|
|||
|
|||
|
I use XHTML 1.0 Strict, CSS, and PHP for everything.
How are they, debian.org and gnu.org, doing it? Are they using seperate files or using cookies? |
|
#4
|
||||
|
||||
|
At dembian, for example, they are probably reading the script name and / or location of the file that is being viewed, then selecting the alternative available languages.
I would disagree about the cookies though - I would have a pages in directories like there languages, eg:
You could, (though not 100% affective) redirect the user initial depending on their accept-language of their browser too. There are lots of ways of doing this. I am sort of (project has cooled down unfortunately) working on a mulit-lingual site at the moment. I have mad all page elements / messages translatable by storing information in INI files, and depending on what language is set, they get info from the ini from the relevant directory. Hope that helps a bit. Need more info, just ask.
__________________
Cheers, Jamie # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure # Any form of employment is strictly prohibited ...... __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. __________________ |
|
#5
|
|||
|
|||
|
Hmmm... I think I'm following.
Do you speak another language? If so, could you go to http://www.debian.org with the browser that uses another language and see if it uses that language or if you have to choose it manually. They use different file names for the languages. I like what they are doing. |
|
#6
|
||||
|
||||
|
Can't do it here, as I only have English as a language set up, work has multiple.
They do have different file names however, but they just seem to be extensions -> for example index.html is index.ar.html in arabian. |
|
#7
|
|||
|
|||
|
I found out that I could use multiple languages with Internet Explorer. I use Mozilla Firebird all the time. So I made Swedish the first priority language. I went to http://www.debian.org and it was in Swedish.
Is it just looking for a file extension with the name of "index.sv.html" because the language is set to "Swedish" or is Debian getting your language setting of your web browser then using the appropriate file. |
|
#8
|
|||
|
|||
|
I will be using different file extensions.
index.en.htm (English) index.sv.htm (Swedish) ... etc. On every page, there will be a list of links to the files with what ever language the file is available in. I also want to have it so that if someone's browser has Swedish as their language, it will automatically open "index.sv.htm" or what ever. How can this task be done? http://www.debian.org does NOT use cookies. I made Swedish the browser language and I said "do not accept any cookies". I went to the web site and it was in Sweedish. |
|
#9
|
|||
|
|||
|
Well, I found the way that they do it. I contacted someone at http://www.debian.org and they told me to go to a certain website, because that's where they learned how to do it. I will show you how you can do it too. Anyone may submit this to DevShed as an article (as long as I get credit).
////////////////////- Begin -//////////////////// I have: Apache/2.0.48 (Win32) First, open up your httpd.conf file. You can find this by going to where you installed Apache. Then go to "Apache2" > "conf" > "httpd.conf" Go to "DirectoryIndex". Add "index.var.txt" and "index.var" if they are not already there. Now, restart Apache. Open up your favorite text editor. Copy and past this into your file: URI: index.en.htm Content-type: text/html Content-language: en URI: index.fr.htm Content-type: text/html;charset=iso-8859-2 Content-language: fr Save that as "index.var" Now make two simple documents. Here is what I used: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>nameofwebsite: Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>This is the English document.</p>
</body>
</html>
Save that as "index.en.htm" Now... Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>nameofwebsite: Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
</head>
<body>
<p>This is the French document.</p>
</body>
</html>
Save that as "index.fr.htm" Now go to your Apache server (usually http://localhost/???????) If you did everything correctly, it should go to the English document (assuming that you have English as your default browser language). You can now change the language setting to French (for your browser) and reload the page, it should now be the French document. If it didn't work try changing the xml:lang and lang in the French document to "en-US". If you use the include/require function in PHP, then all you have to do is include/require the 'x' language version. In the English document, you would have: <?php include_once("http://localhost/www/mainmenu.en.htm"); ?> OR <?php require_once("http://localhost/www/mainmenu.en.htm"); ?> In the French document, you would have: <?php include_once("http://localhost/www/mainmenu.fr.htm"); ?> OR <?php require_once("http://localhost/www/mainmenu.fr.htm"); ?> Good luck, have fun, and happy coding! Last edited by MasterChief : January 17th, 2004 at 08:23 PM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Web Design Help > Using multiple languages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|