0
votes

We have done the website content in English language, now we want to add multilingual option to the website. There are more contents in English language, all content needs to convert into new language.

I can Create a table like this

 content_id
 en_title
 ar_title
 fr_title
....

But more existing content are there in English. Any guidance would be appreciated.

2

2 Answers

1
votes

You could devide the page into 2 tables

page
- id
- other info that is generic

part
- id
- part_id
- page_id
- language
- content

Now you can say get the contents of page x with the language y. Also you can "easily" (need to translate a lot :P ) add new languages, just throw them in the part table


I added the part_id to part. This way you can say something like i want from page x the part id y, with language q.

0
votes

Most basic implementation for i18n can be done through language files. It involve 3 major steps

Step 1: Define language files

For your example, define 3 files en.php, fr.php and ar.php (or more for more languages). Better keep all these files in 'language' folder. File contents will be like

<?PHP
$LANG_LABEL_TITLE = "Title in specific language";

step 2: Include language file

There must be a common script for all your web accessible files; central controller or at lease a common header. In that file, detect default browser language and set it in session. Again include required language file there.

step 3: Use labels

Once you have required language file included, simple use the label at required position like

<title><?PHP echo $LANG_LABEL_TITLE; ?></title>

Again this is the most basic implementation. Go through it and if you stuck somewhere, ask question specific to that part.