Solved

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

Posted on 2011-09-11
6
255 Views
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?
0
Comment
Question by:rayluvs
[X]
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
6 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 333 total points
ID: 36520302
PHP uses different directories for different languages.  Example:
http://php.net/manual/en/function.var-dump.php
http://php.net/manual/kr/function.var-dump.php
http://php.net/manual/de/function.var-dump.php

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

Assisted Solution

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

1. lazy method use: Widget:

http://translate.google.com/translate_tools

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:

eng.lang.php
kr.lang.php
jp.lang.php

each lang files represent different language:
$lang['edit.success'] = 'Video was successfully updated!';
$lang['global.video'] = '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['global.video'] = '¿¿¿';
$lang['global.point'] = '¿¿¿¿';
$lang['global.points'] = '¿¿¿¿';
$lang['global.time'] = '¿¿';
$lang['global.times'] = '¿¿';

Open in new window

$lang['edit.success'] = 'Filmy zaladowane pomyslnie!';
$lang['global.video'] = '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:
http://www.bitrepository.com/php-how-to-add-multi-language-support-to-a-website.html
and
download the example here:


php-multi-language-site-bitrepos.zip
0
 

Author Comment

by:rayluvs
ID: 36521310
Thanx... We'll check it out
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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.
0
 

Author Comment

by:rayluvs
ID: 36558034
Thanx!
0
 

Author Closing Comment

by:rayluvs
ID: 36558036
Thanx
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 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