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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 110

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

LVL 110

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

724 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