Creating multilingual website
Moderator: General Moderators
Creating multilingual website
What would be the best way to create a multilingual website? Saving strings in mysql and make every language has its own table? I really don't have an idea on how to do this so any help is appreciated.
Re: Creating multilingual website
There is no need of a table for every language.
Usually multilingual support is created with just one extra table for each table that has text fields
For example if you have:
products
----------
product_id
category_id
title
description
price
in multilingual architecture it will look like:
products
----------
product_id
category_id
price
products_ml
----------
product_id
language_id
title
description
The user interface can use either language files that contain all the string, or also a database table, if templating engine permits it.
Usually multilingual support is created with just one extra table for each table that has text fields
For example if you have:
products
----------
product_id
category_id
title
description
price
in multilingual architecture it will look like:
products
----------
product_id
category_id
price
products_ml
----------
product_id
language_id
title
description
The user interface can use either language files that contain all the string, or also a database table, if templating engine permits it.
Re: Creating multilingual website
Lets say I want to use it via language files (so it would be lang_english.php, lang_german.php, lang_spanish.php) which have the same strings (which are stored into variables) and just translate the text of these variables - how would I import it into lets say index.php? Using include function and then just put the variable names into the corresponding spots? Or there is easier way to do this?
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Creating multilingual website
The method you describe is a common way of creating a multilingual website.
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Creating multilingual website
I would encourage you to use different .php files for every language. And in each of those PHP files you should make an array which holds the language strings. For example, in the lang_eng.php it will be something like this:
$lang['What_is_your_name'] = 'What is your name?';
in the german file it will be something like this:
$lang['What_is_your_name'] = 'Wie heisst du?';
Then you will check what language has been selected and add the selected language into a session variable:
if($_POST['language'] = 'eng') {
$_SESSION['language'] = 'eng';
} else {
$_SESSION['language'] = 'de';
}
include('lang_'.$_SESSION['language'].'php');
Something like this...
$lang['What_is_your_name'] = 'What is your name?';
in the german file it will be something like this:
$lang['What_is_your_name'] = 'Wie heisst du?';
Then you will check what language has been selected and add the selected language into a session variable:
if($_POST['language'] = 'eng') {
$_SESSION['language'] = 'eng';
} else {
$_SESSION['language'] = 'de';
}
include('lang_'.$_SESSION['language'].'php');
Something like this...