Hello every body.
I need to make a site in 6 languages with php. Languages are like english, hindi, polish, romanian etc. I want to ask what is the best solution to make a site in different languages. The site i need to make is CMS and a forum.

Please tell me what are the expected solutions are which one is the best solution.

Please describe in detail.

one word: google.

google translations will help you a lot. A simple google search will give you your answers.

Hi arshadshaikh,

I'm no expert but I can tell you how I just created a similar site not long ago and leave it to smarter people to either confirm what I did or point out it flaws.

Basically the site was available in 6 languages and was all powered by a CMS. Although I had no forum so can't advise on this aspect.

The high level overview of my system was that I created a database for the English language and got the site working for that, pulling and writing etc. Then I copied the English database and renamed it for each language. IMPORTANT; I set the Coalition of the database as UTF-8 so it can handle most languages.

Then in my PHP I basically set a cookie for the language the user picked and use the value in that cookie in my database connection settings to pull from the database associated with that language.

It worked pretty well.

Hope this helps.

One method you could use is to create the site with english coding (so you can read it) but leave all the words that are to be displayed on the screen in foreign places such as .txt files that you can include. I would then store these in separate folders according to language, and use a $_SESSION or $_COOKIE variable to store the current language and use this variable to determine which .txt file is retrieved.

eg:

<?php
/
  index.php
  /en
    /en/images
    /en/articles
    /en/etc...
  /de
    /de/images
    /de/articles
    /de/etc...
  /etc...

This means that a path can be constructed using a variable. eg:
$path = "../$lang/images/pic1.jpg";
index.php will draw on the resources in those files
?>

As including a .txt file is only actually helpful for large clumps of text, you can use language files to load constants.

For example en.index.php contains:

define ("PAGE_TITLE", "My Site");
define ("TEXT_USERNAME", "Username");
define ("TEXT_PLS_ENTER", "Please enter the following details:");
define ("TEXT_SUBMIT", "Submit");

And file index.php contains

<?php
$file = $lang.".index.php"; //You can use PHP_SELF some how here i think
include $file; //I think that will work...
//from this point on the constants defined in en.index.php can be used like follows:
?>
<html junk here>
<?php
echo TEXT_PLS_ENTER . "<br/>\n";
echo '<form>'.TEXT_USERNAME.'<input type="text" name="username" />';
echo '<input type="submit" value="'.TEXT_SUBMIT.'" /> </form>';
?>
</html junk>

You get the idea.

EDIT: Oh yeah, and what rickya said, make sure you only grab data from the corresponding database for each lang.

I think i will need to go for google translatiion API... which would be better.

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.