hi i wrote a page in php that have strings which should translate to other language in UTF-8 Unicode . i want to write translation in other page and load it in main page .
how to do it ? tell it by example if you can plz .
translate to other language
Moderator: General Moderators
-
ahad_yekta2004
- Forum Newbie
- Posts: 6
- Joined: Fri Jul 23, 2010 2:00 am
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: translate to other language
You want a multilanguage page?
Re: translate to other language
Put the different strings to be translated in language-specific arrays, such as:
Build your page to include those language strings:
Then, you can just change the $language variable to 'es' to change the page to Spanish, or 'fr' to change it to French.
Code: Select all
<?PHP
$lang['en']['hello'] = 'Hello';
$lang['en']['person'] = 'person';
$lang['es']['hello'] = 'Hola';
$lang['es']['person'] = 'persona';
$lang['fr']['hello'] = 'Bonjour';
$lang['fr']['person'] = 'personne';?>Code: Select all
<?PHP
$language = 'en';
?>
<html>
<head>
<title>
<?php echo $lang[$language]['hello'].' '.$lang[$language]['person']; ?>
</title>
...
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.