What's the best practice to change labels content in PHP when depending on the language chosen by users

Posted on 2011-09-11
Last Modified: 2012-05-12
We have an old application in PHP developed in the English language.  We would like to change the application to either show English or another language.

Based on EE experience in this area, whats the best way to go about it?
Question by:rayluvs
  • 3
  • 2
LVL 109

Accepted Solution

Ray Paseur earned 333 total points
ID: 36520302
PHP uses different directories for different languages.  Example:

You might consider having a Wiki so that native language speakers can contribute to the new language capabilities.

Assisted Solution

boon86 earned 167 total points
ID: 36521294
there is 2 way to accomplish this:

1. lazy method use: Widget:

this method will have multiple language on your site that translate by google translator

2. translate your whole site manually

you will need to translate all the terms to store it into languange files example:


each lang files represent different language:
$lang['edit.success'] = 'Video was successfully updated!';
$lang[''] = 'video';
$lang['global.point'] = 'point';
$lang['global.points'] = 'points';
$lang['global.time'] = 'time';
$lang['global.times'] = 'times';

Open in new window

$lang['edit.success'] = '¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿';
$lang[''] = '¿¿¿';
$lang['global.point'] = '¿¿¿¿';
$lang['global.points'] = '¿¿¿¿';
$lang['global.time'] = '¿¿';
$lang['global.times'] = '¿¿';

Open in new window

$lang['edit.success'] = 'Filmy zaladowane pomyslnie!';
$lang[''] = 'filmy';
$lang['global.point'] = 'punkt';
$lang['global.points'] = 'punkty';
$lang['global.time'] = 'czas';
$lang['global.times'] = 'razy';

Open in new window

then call them using session:

if ($config['multi_language'] && isset($_POST['language'])) {
	$language = trim($_POST['language']);
	if (isset($languages[$language])) {
		$_SESSION['language'] = $language;
require  '/language/'.$_SESSION['language'].'.lang.php';

Open in new window

3. Refer tutorial here:
download the example here:

Author Comment

ID: 36521310
Thanx... We'll check it out
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 333 total points
ID: 36521744
Depending on the kind of information your site carries, you might find the Google translator useful, or not.  Some things like "hydraulic ram" tend to turn into things like "water goat" so you would want to set up good test cases before you rely on the translator.

Author Comment

ID: 36558034

Author Closing Comment

ID: 36558036

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php help 34 58
MVC - procedural PHP 10 36
Undefined Variable: loop_limit, Undefined Variable: number 3 17
jQuery Toggle & Anchor Links 5 43
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question