I would like to know what you think about the way I deal with the PHP multi-language feature for my website.
First, I recover a variable $config['UserLang'] which contains the language. I recover it from the $_SESSION or from the database if the user is connected and has specified a language.
$config['UserLang'] = 'fr';
Then I open a file containing constants of the language:
require_once ('include/langs/'.$config['UserLang'].'.inc.php');
In the directory include/langs I have as many files as available languages, for example: en.inc.php, fr.inc.php and es.inc.php
And for example, the content of en.inc.php will be:
define("LANG_HOME_home", "Home");
define("LANG_HOME_contact", "Contact us");
define("LANG_HOME_phone", "Our phone");
define("LANG_HOME_address", "Our address");
define("LANG_HOME_desc", "Some description of the company <br> Another line about the company");
And then, when I display the DOM:
echo '
<div class="pad-t-20 txt-c">
'.LANG_HOME_desc.'
</div>';
It's working fine bu is there anything I could to to improve it? Is there any other way which would be more conventional?
Thanks.