View Issue Details

IDProjectCategoryView StatusLast Update
0015654phpList 3 applicationInternationalization (l18n)public30-05-12 22:21
Reporterduncanc Assigned To 
Status resolvedResolutionfixed 
Product Version2.10.16 
Fixed in Version2.11.7 
Summary0015654: Unnecessary multiple including of language files
DescriptionI installed the APC (Alternative PHP Cache) extension to see what effect on response times it would have and as a side effect found that the language files are included not just once but on every call to the phplist_I18N class get method.
APC shows the number of times each file is included/required and showed these results:

to display the home page once:
included en/home.php 84 times
included en/common.php 38 times

to display the users page once:
included en/users.php 114 times
included en/common.php 39 times

Although phplist 'is fast enough' it seems a good idea reduce the number of times each file is included.
My proposed solution is to load the language file for the page, and the common and frontend language files in the constructor instead of in the get() method. Additionally, to accumulate the files into a single array so simplifying the lookup processing in get().

Attached is a modified languages.php, taken from the 2.10.17 release.
The changes are only to the phplist_I18N class:
1) added instance variable $this->lan, which is set in the constructor and read in the get() method
2) moved the loading of the languages files from the get() method to the constructor, into a single array $this->lan
3) simplified the lookup of the text in the get() method

The lookup logic, initially in the page file then falling through to the common file, then to the front-end file, has been replaced by merging the files into a single array.
The lookup logic of the text, then the lowercased text, then the uppercased text is unchanged.
TagsNo tags attached.



29-01-12 19:37

updater (6,443 bytes)


29-01-12 19:39

updater   ~0051437

I have added the modified languages.php that I refer to in the original description. When I originally added the issue, adding attachments seemed to be broken.


10-02-12 14:26

administrator   ~0051459

Hmm, the main issue with this is that each term is looked up differently.

eg, one term in a page may be in lan/[iso]/page.php and the other in lan/[iso]/common.php

I'm redoing the translation system to use the gettext method, and this should be included.


10-02-12 16:32

updater   ~0051460

The current code looks-up a term in the order - the 'page' file, then the 'common' file, and then the 'front-end' file.

My change loads the files in the same order into a single array, so a term should be found from the 'page' file if it is present there, otherwise found from the 'common' file if present there, and finally from the 'front-end' file if present there.
If a term appears in more than one file then the earlier takes precedence.


10-02-12 16:40

administrator   ~0051461

ah, yes, of course, good point


30-05-12 22:21

administrator   ~0051652

the language.php file had changed a lot in the meantime, but I've incorporated your changes manually.