Hi friends..

I am going to do the project in different languages...Anybody explain me how to do that...any procedure...any softwares...atleast how can i start the project...

Thanks in advance.....
Advance Happy Rakhi TO All

You just need to know the UTF encoding for all characters of the other language .

Member Avatar for diafol

There are many ways in which to do this. You could use GETTEXT and PO/MO files (a bit fiddly if you're new to that sort of thing).

My personal way of working is to take out all static text from the website and have PLACEHOLDERS for certain words, sentences, etc.

The language files, with a list (array) of words, sentences, etc will then typically be stored in a folder called 'i18n' (short for internationalization) or 'lang'. I name the specific language file according to the 2 letter language code and 2 letter country code, with the 'php' extension, for example:

cy-GB.php (for Welsh)
en-GB.php (for British English)

The structure of the files would be something like:

//in the cy-GB.php file:
$txt = array(   
'general_title' => 'Croeso i\'r Safle',
'general_subtitle' => 'Dyma Brawf',
'general_tagline' => 'Dim byd i ddweud',
... (etc) ...

//in the en-GB.php file:
$txt = array(   
'general_title' => 'Welcome to the Site',
'general_subtitle' => 'Here\'s a Test',
'general_tagline' => 'Nothing to say',
... (etc) ...

Your webpage:

//get your current language-country and place it into the variable $lang and load the language file
...(dtd; head; etc)...

<h1><?php echo $txt['general_title'];?></h1>
<h2><?php echo $txt['general_subtitle'];?></h2>
<p><?php echo $txt['general_tagline'];?></p>

You can shorten the code from < ?php echo $txt['something'];?> to <?= $txt['something'] > if your server supports it. These are known as short tags - they are heavily frowned upon, but there again...

Templating systems, like Smarty can further reduce the size of the code, but they tend to add a greater degree of complexity.


If you want to have dynamic text in a number of languages (e.g. a bilingual blog), just have double the number of database fields in your tables. I've attempted creating new tables for each language, but I had terrible problems "synching" the records, as id values could be different in each language table. So having fields such as:


seems to work well for me. However, this could be a bit of a nightmare were you to add further languages. As long as you had a list of all the tables you needed to modify, it should work. In addition, each language should have a 'fallback' language in case a string or entry did not exist, so an English entry would appear if a Welsh one didn't exist.

Depending on the size of the website, you may want to create more than one language file to compartmentalize the strings. For example admin area strings needn't be included in the normal language file. It saves loading loads of unnecessary strings. I wouldn't go so far as to create a language file for every page though.

commented: Great suggestions, well-explained with good examples :) +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.