[wp-trac] Re: [WordPress Trac] #3089: Localized values for plugin metadata

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 10 00:50:07 GMT 2008


#3089: Localized values for plugin metadata
-------------------------------------+--------------------------------------
 Reporter:  nbachiyski               |        Owner:  ryan    
     Type:  enhancement              |       Status:  reopened
 Priority:  normal                   |    Milestone:  2.7     
Component:  i18n                     |      Version:          
 Severity:  major                    |   Resolution:          
 Keywords:  has-patch tested phpdoc  |  
-------------------------------------+--------------------------------------
Comment (by codestyling):

 Replying to [comment:53 DD32]:
 > AFAIK, most plugins with translations load them on the init hook anyway,
 so they should be loaded allready, However that code doesnt check to see
 ifs its been loaded yet, so you could end up with the translations being
 loaded twice..
 >
 > Due to the way the l10n code is written, AFAIK there isnt a way to
 unload any given translation file, since each translation file loaded is
 merged with eachother in memory.
 The loading of active plugins may be this way. Several good pluginwriter
 try to load them as lazy as possible or if their admin page(s) really
 get's displayed.
 But this is not the point. Let's say you have 10 activated plugins (may be
 ok for memory) but 150 deactivated ones each having a translation file.
 The start of loading now 160 *.mo files will crash the script memory usage
 definitely.

 And merging occures only, if more than one plugin gots the exact same
 textdomain name because for each textdomain name a hash entry with key =
 textdomain name and value = gettext object will be stored internally.

 '''Suggestion:''' It will first need a test, if the textdomain name
 exists. If so, never unload it but use it without loading again the
 textdomain *.mo file.
 If the textdomain name is not available at the hash, mark this temporary,
 load it, translate it and cleanup an free that entry now.
 Doing so, you only keep those already have been loaded before and get a
 safe unload for temporary translation needs because you add temporary only
 1 new *.mo per loop scope start and  gets it unloaded at loop scope end.
 After loop finalization the translation object cache (hash map) is at same
 state as before.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3089#comment:54>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list