language files
| From: | Ryan A | Date: | Thu, 07 Apr 2005 02:52:15 +0000 |
| Subject: | language files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-212482@lists.php.net to get a copy of this message | ||
Hey,
I was just wondering which is the best/most efficient way of having language
files for a site?
eg:
if $lang=english then it should include lang.en.inc.php
if $lang=swedish then it should include lang.se.inc.php
etc
One way I did it before was to have an array like so:
$lang_en[0]="Enter username";
$lang_en[1]="Enter password";
etc
and then in the main php files I include the above language files and in the
print/echo statements I echo $lang_en[x].
It works quite well but just looking at the code its quite easy to get
confused because of all the $lang_en[x] statements...and you have to
constantly check the language file and the array number to know whats where,
I though of using short workds like
$get_user="Enter your username:";
$get_pass="Enter your password:";
but then sooner or later you are going to use the same variable and
overwrite what you wrote before if you are not careful..esp if you have a
lot of text on your site...or a large site....which will produce some weird
results till you notice your mistake...
So.....how have you guys done it....or ....any advise on doing it? pointers?
tips? ideas?
Cheers,
Ryan
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.4 - Release Date: 4/6/2005