473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

multilanguage website

I'm trying to make a multilanguage website. When the user enters the site, I want to detect the language and automatically make a redirection. How can I do this? And how should I organize my data base so the user can switch languages easily?

Thanks.
Jul 16 '05 #1
5 16645
Mariano López wrote:
I'm trying to make a multilanguage website. When the user enters the
site, I want to detect the language and automatically make a
redirection. How can I do this? And how should I organize my data
base so the user can switch languages easily?

Thanks.


Detecting language... not easy at all. You could try to do a reverse lookup
on the IP address and grab a country from that, but that may be slow.
Personally, I would display either a map of the world with regions
clickable, or (my personal preference) flags. Then just keep that in the
query string (e.g. blah.php?lang=en) or in a session variable (perhaps less
preferable if you have a ton of users). When querying your db for content,
just tack on an extra row (of type enum) for the language.

My $.02
// Ian Fette
// Proponent comp.lang.php
Jul 16 '05 #2
Agelmar wrote:
Mariano López wrote:
I'm trying to make a multilanguage website. When the user enters the
site, I want to detect the language and automatically make a
redirection. How can I do this? And how should I organize my data
base so the user can switch languages easily?

Thanks.


Detecting language... not easy at all. You could try to do a reverse
lookup on the IP address and grab a country from that, but that may
be slow. Personally, I would display either a map of the world with
regions clickable, or (my personal preference) flags. Then just keep
that in the query string (e.g. blah.php?lang=en) or in a session
variable (perhaps less preferable if you have a ton of users). When
querying your db for content, just tack on an extra row (of type
enum) for the language.

My $.02
// Ian Fette
// Proponent comp.lang.php


Hi. I've found an easy solution to language detection by using Javascript (it checks the browser's language configuration).

Now I'm thinking if I'm going to use a session variable (I didn't want to mess with it, but maybe I do ;-)))

Thanks.
Jul 16 '05 #3
sam
You can use the ip-to-country database.

---------------- CUT HER ------------------------------
$user_ip = $_SERVER['REMOTE_ADDR'];
$country_code_type = "name"; // can be "name", "code2" or "code3"

$h =
fopen("http://ip-to-country.directi.com/country/$country_code_type/$user_ip"
,'r');
$user_country = fgets($h,4096);
fclose($h);
---------------- END -----------------------------------

You can download the database from http://ip-to-country.directi.com and
you access it locally if you want.

For more details: http://ip-to-country.directi.com

Hope this helps.
"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:be************@ID-156496.news.uni-berlin.de...
I'm trying to make a multilanguage website. When the user enters the site, I
want to detect the language and automatically make a redirection. How can I
do this? And how should I organize my data base so the user can switch
languages easily?

Thanks.
Jul 16 '05 #4
You might want to look over some HTTP request headers:

$_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ]

Or look over get_browser(), there is one of the values that identifies
the browser's language if I remember well, but it should be the same value.

Agelmar wrote:
Mariano López wrote:
I'm trying to make a multilanguage website. When the user enters the
site, I want to detect the language and automatically make a
redirection. How can I do this? And how should I organize my data
base so the user can switch languages easily?

Thanks.

Detecting language... not easy at all. You could try to do a reverse lookup
on the IP address and grab a country from that, but that may be slow.
Personally, I would display either a map of the world with regions
clickable, or (my personal preference) flags. Then just keep that in the
query string (e.g. blah.php?lang=en) or in a session variable (perhaps less
preferable if you have a ton of users). When querying your db for content,
just tack on an extra row (of type enum) for the language.

My $.02
// Ian Fette
// Proponent comp.lang.php


Jul 16 '05 #5
Mariano López wrote on Saturday 12 July 2003 12:10:
I'm trying to make a multilanguage website. When the user enters the site,
I want to detect the language and automatically make a redirection. How
can I do this? And how should I organize my data base so the user can
switch languages easily?


If you run Apache or any capable web server, then you can leave the client
language detection and preference to it and let it serve appropriate
file(s). See more in Apache docs.

Then, based on which file is served, set language preferences in your PHP
app and allow change back and forth. As far as separating data, make sure
all language-specific content is defined separately from your main
application, and include() language-specific include files (containing
appropriate variables and language-specific content) in each script that
outputs or otherwise processes said content.

Depending on complexity of your application, and variety of languages this
could be anywhere from very simple to somewhat challenging.

--
Business Web Solutions
ActiveLink, LLC
www.active-link.com/intranet/
Jul 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Markus Ernst | last post by:
Sorry for the multipost - I forgot to crosspost and alt.php gets less attention than comp.lang.php... And I hope this will work with UTF-8. In order to make strings suitable for URLs in a UTF-8...
0
by: Giovane Calabrese | last post by:
ok. im try to make a multilanguage system based on that tutorial : http://www.123aspx.com/redir.aspx?res=29112 in my aspx pages all text are in labels , and i want to take the name labels...
1
by: Andrew Smith | last post by:
Hi, does anybody know to program multilanguage website, which are dependend on the browsers language settings? Does anybody know a nice jumpstart for this? Thanks in advance for any advice...
5
by: Michal Táborský | last post by:
I am wondering, if it's effective to use text arrays to store multilanguage information. We used to do it like this: CREATE TABLE product ( id serial NOT NULL, price float4, ... )
0
by: HelmutStoneCorner | last post by:
Hi, I am connected as a german client to a multilanguage server, Regional Options: English, US. Western Europe and US. The W2K Server (Terminal) -version: english(US) runs a french database. My...
15
by: AG | last post by:
I have seen the samples for multilanguage support regarding what is normally static content. Can anyone point me to a good sample for multilanguage support for dynamic content. Like a gridview...
1
by: paolob | last post by:
I need to provide multilanguage support to my application. I alredy writed a multilanguage test application, using VS6 and resource only dll. Now i'm using Visual Studio 2005, I find out that it...
1
by: schneider | last post by:
Hi all, I'm planning to create a multilanguage-capable website in asp.net 2.0, using c#. I have read some very nice articles about internationalization and localization. A common hint is using a...
1
by: mmr315 | last post by:
Hi All, This is mahesh. I am developing a site for online hotel booking. I need help in php for converting my website in to different language when user click on language the current page should...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.