storing translations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cold
Forum Newbie
Posts: 1
Joined: Mon Apr 09, 2007 1:56 pm

storing translations

Post by cold »

-translations for different languages are stored in .ini files.
-the choosen language is stored in a $_session['lang'] variable.
-for every file accessed i load the .ini file representing the $_session['lang'] and store it in the _strings() array.and use those strings for substitution.

The Question: is it better if i store the translated text once in a similar $_session variable for use during the whole session.or better to create a new instance of the i18n class and reload the .ini translation file for every new page the user access?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

The 'better' is a vague word. Personally I would not store such data into session.

Performance-wise it would be best to store the data into ini files and cache it in a shared memory segment on the first load.
Post Reply