RE: [PHP] language files
| From: | Kim Madsen | Date: | Thu, 07 Apr 2005 07:48:57 +0000 |
| Subject: | RE: [PHP] language files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-212513@lists.php.net to get a copy of this message | ||
Hi there
> -----Original Message-----
> From: Ryan A [mailto:ryan@coinpass.com]
> Sent: Thursday, April 07, 2005 5:37 AM
> have you ever double entered the same words?
Well, if You do that, the later is the overwriting the previous ;)
> eg:
> $lang['login_username'] = 'Username: ';
> $lang['login_password'] = 'Password: ';
> .... (much further down)
> $lang['login_username'] = 'Enter username: ';
>
> and using the above method I bet that sometimes the key in the array gets
> pretty big (if you are trying to put a hint of the context in
> too)...correct
> me if i'm wrong, i'm just guessing here.
>
> The problem I feel is, when you are making the script everyhing is fresh
> in
> your mind and you are unlikely to make silly mistakes like the example one
> above, but come back to a script after a few months and its an entirely
> different story, esp if you have been working on other projects in
> between...
You´re right. The solution to this issue is to use a database and have the field containg the key
for $lang set as unique. But then You will have new issues to think through, like database load.
Fetch from database on each page request? Or put all translations in a SESSION? Then what if You
adds new translations and a user enters that page with the old SESSION? And so and so
A much better solution is to have a GOOD procedure when adding new word and pages. It´s fairly easy
to search the translation document for the new keyword like login_username to see if it´s
available, right? It doesn´t take that much effort to maintain that procedure ;-) If You think so
maybe a database api, where You enter a new keyword and the text, and if that is inserted well, then
the api generates a new list.
I was programmer and project manager on translation when the ISP World Online was using the Denmark
site/system to start up in Norway and Sweden. Our solution was a function, that fetched the data
from a text file in a sub dir (da/se/no) set by a configfile.
I´ve later improved the solution when creating a Multilanguage site for a bar in Cyprus. You can
have a look at gg.emax.dk and the langfile is here: http://gg.emax.dk/language/UK/lngfile.txt
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/systemdeveloper