Jump to content


This topic is now archived and is closed to further replies.


multilanguage website

Recommended Posts


I want to build a website that supports multiple languages. Starting with English and Japanese.
Is there someone who has done this and can give me some hints mainly on database design ?
The biggest problem I have is how to make menu's in multiple languages ?
Do I write a separate function or page for every language or can I do this by using a database ?

any help or links to tutorials is greatly appreciated


Share this post

Link to post
Share on other sites
I have never had to do anything like BUT perhasp the trick would be to follow how applications on your own computer work.

create a table to act as a resource file.

for each string (one or more words) creata an entry in the table and have the fields of the table be the language ie.

CREATE TABLE `language` (
`string_ID` int(11) NOT NULL auto_increment,
`english` varchar(255) default NULL,
`german` varchar(255) default NULL,
PRIMARY KEY (`string_ID`),
KEY `english` (`english`,`german`)

-- Dumping data for table `language`

INSERT INTO `language` VALUES (2, 'Good Bye', 'Aufwiedersehen');
INSERT INTO `language` VALUES (1, 'Hello', 'Guten Tag');
INSERT INTO `language` VALUES (3, 'I am', 'Ich bin');

Then in your code you need only reference the string code and allow a session variable to select the correct field to display.

That is how I would approach it. On a point of page design - make sure you define a lang attribute for either the whole page or the relevant elements - it will help the browser and the user.

Share this post

Link to post
Share on other sites
I have been thinkin about the language problem

I was thinking about making a table
and have the following columns
id (primary key)
01 (english)
02 (japanese)
03 (french)

content (table that holds articles, reviews)
id (primary key)
title 01 (english title)
title 02 (japanese title)
title 03 (french title)

text 01 (english text)
text 02 (japanese text)
text 03 (french text)

another thing is how to make the browser understand that it has to display a different language ?
and worst of all is when you have two languages on the same page (english japanese combination is always fun)

Share this post

Link to post
Share on other sites
Hi, Im actually working on a multilanguage proyect. Basically I have the following DB structure:

| Tables_in_webadmin |
| content                |
| idiomas                  |
| images                  |
| pages                    |
| sections                |
| sistemas                |
| translators            |
| users                    |

content has the following structure:
| Field      | Type        | Null | Key | Default | Extra |
| id        | varchar(40)  | NO  | PRI |        |      |
| comentario | varchar(150) | YES  |    | NULL    |      |
| seccion    | int(5)      | NO  |    |        |      |
| pagina    | varchar(30)  | NO  |    |        |      |
| es        | longtext    | NO  |    |        |      |
| en        | longtext    | NO  |    |        |      |
| pr        | longtext    | NO  |    |        |      |

-id I use it as an unique referal string ->Example: _VPNAMEPRODUCT
I would recomend to use a descriptive name of what you are going to set under that key.

-comentario: Serves as a description or comment for the key that you are using -> Example: Name of the product

-seccion: I splitted the web into diferent main sections
-pagina: I splitted every section into diferents pages

then you create a colum for every language you need: I have for example: es -> Español, en->English, pr->Português

That was the main table, the others are self explanatory or you might not need them.

I created a file in PHP with the following function:

*  Defines constants of a section and page
*  Parameters ->
*  $idioma: Language your want (Example: es, en)
*  $seccion: (optional) Section from wich you need the constants
*  $pagina:  (optional) Specific page from wich you need the constants
*  Notes: You will need a prev connection to the DB
*  Created by Jorge Pedret 22/02/2007

function getConst($idioma, $seccion="", $pagina=""){

$qGetconst = "SELECT id, $idioma FROM content WHERE seccion='$seccion'";
if($pagina != ""){
$qGetconst .= " AND pagina='$pagina'";
//echo $qGetconst;
$constantes = mysql_query($qGetconst) or die("The language you are looking for does not exist");
//$constantes = mysql_query($qGetconst);
//echo mysql_error();
if(mysql_num_rows($constantes) > 0){
while($cons = mysql_fetch_array($constantes)){
//Definicion de las constantes en el archivo
define($cons['id'], $cons[$idioma]);
//echo $cons['id'];
} else {
return false;

Then in the file that you need text, you will just include the functions.php file and call for example -> getConst('en', 'web', 'products');
then just print the constant that you are looking for: <?=_VPNAMEPRODUCT?>

For images, try to use images without text, and position de text over the image with css

If you really need images with text in it, use the images table and save the url of the image and call it on the web:
<img src="<?=_VPIMGURL?>" />

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.