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.

Dani AI

Generated

A practical, maintainable approach for a PHP CMS + forum is to separate translation of user interface strings from translation of stored content and to keep one canonical schema rather than duplicating databases or many hard-coded language files.

Use a single content table and a linked translations table so every piece of content has one record plus zero-or-more language variants. For example:

CREATE TABLE content (
  id INT PRIMARY KEY AUTO_INCREMENT,
  slug VARCHAR(200) NOT NULL,
  created_at DATETIME NOT NULL
);

CREATE TABLE content_translation (
  id INT PRIMARY KEY AUTO_INCREMENT,
  content_id INT NOT NULL,
  locale CHAR(5) NOT NULL,
  title VARCHAR(255),
  body TEXT,
  UNIQUE (content_id, locale),
  FOREIGN KEY (content_id) REFERENCES content(id) ON DELETE CASCADE
);

Fetch logic: load the requested locale row; if missing, fall back to the canonical language. This keeps searches, URLs, and permissions unified and avoids schema drift when features change.

For UI text, use a proper i18n/catalog system (PO/MO, JSON message files, or PHP-intl) to handle plural forms and locale rules—this scales much better than sprinkling translated strings through code. For forum posts, store the original language on the post and allow community or translator-added translations as separate records; show machine-translated text only with a clear “auto-translated” label and let users report bad translations.

Notes and pitfalls: ’s machine-translation idea is useful for drafts but not a substitute for review. ’s per-language database approach works initially but multiplies maintenance work. ’s language-file method is fine for static UI strings but becomes awkward for dynamic CMS content. Also plan for SEO (locale-aware URLs and hreflang), caching of translation lookups, locale-aware date/number formatting, and a translator workflow (export/import or a simple in-app translator UI) so ongoing edits stay consistent.

Recommended Answers

All 4 Replies

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.