December 3rd, 2013, 04:52 AM
Handling languages - suggestion please?
How would/should I go about handling different languages? at the moment i do something like:
// on the actual page
$lang = "english";
...somewhere down the page:
$lang['english'] = array (
'hello' => Hello
December 3rd, 2013, 06:57 AM
stuffing the translations into a PHP array and including it in the main script doesn't sound like a good idea. It requires you to constantly mess with the PHP source code, and if you (or anybody working on the translation) ever produce a syntax error, the whole application will uncontrollably crash. Personally, I also don't like the PHP syntax noise.
I basically see two options:
If you're the only one to work on the language entries, and if you rarely change them, put them into external JSON files (or any format you like, YAML, XML, whatever).
If many (non-tech) people work on the entries, or if they're changed very often, consider putting them into the database and writing a simple GUI for editing.
It might also make sense to cache the entries in case you experience performance issues.
December 17th, 2013, 11:17 AM
didnt see the reply until now.
Thanks for your suggestion. I was going to put them into a database but thought there would be too much of a headache in terms of php having to do more work and cause delays. (some of my script are already causing this issue ).
how would I go about the option 1? would there be one XML per language or?