Jump to content

[Confused] Translations


PF2G

Recommended Posts

Hi,

 

I'm working on a website where i have to translate the pages and the way i have to do is a little confused. Here it goes:

 

I have to create 2 files lang_pt.php and lang_en.php where i have common arrays where i do the translation.

 

lang_pt.php:

<?PHP
$lang['Family Office']="Family Office";
$lang['Multi Family Office']="Multi Family Office";
$lang['Foco']="Foco";
$lang['Serviços']="Serviços";
$lang['Valores']="Valores";
$lang['Seminários']="Seminários";
$lang['Contactos']="Contactos";
$lang['Português']="Português";
$lang['Inglês']="Inglês";
?>

 

lang_en.php:

<?PHP
$lang['Family Office']="Family Office";
$lang['Multi Family Office']="Multi Family Office";
$lang['Foco']="Foco";
$lang['Serviços']="Services";
$lang['Valores']="Values";
$lang['Seminários']="Seminars";
$lang['Contactos']="Contacts";
$lang['Português']="Portuguese";
$lang['Inglês']="English";
?>

 

Then i have to include this 2 files in another, common.php. An it's here where i get confused....I have to include the files in this common.php and then i have to do a switch for the languages (i'm not sure if it's correct):

<?PHP
$lang=$_GET['lang'];
include 'lang_pt.php';
include 'lang_en.php';

echo $lang['Family Office'];
echo $lang['Family Office'];
echo $lang['Multi Family Office'];
echo $lang['Foco'];
echo $lang['Serviços'];
echo $lang['Valores'];
echo $lang['Seminários'];
echo $lang['Contactos'];
echo $lang['Português'];
echo $lang['Inglês'];

switch ($lang) 
{
	case "lang_pt.php":
		header ('Location: index.php?lang=pt');
		die();
		break;
	case "lang_en.php":
		header ('Location: index.php?lang=en');
		die();
		break;
	default:
		header ('Location: index.php?lang=pt');
		die();
		break;
}
?>

 

Then include the common.php in all other files so it can do the translation.

 

I think this is the most clear i can be. If someone can help me, i appreciate.

 

I'll try to explain better if you want to.

 

Thank You,

PF2G

Link to comment
https://forums.phpfreaks.com/topic/263330-confused-translations/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.