[wp-trac] [WordPress Trac] #37997: Increase in function calls to get_locale() because of _load_textdomain_just_in_time()

WordPress Trac noreply at wordpress.org
Tue Nov 8 21:11:34 UTC 2016


#37997: Increase in function calls to get_locale() because of
_load_textdomain_just_in_time()
-------------------------------------------------+-------------------------
 Reporter:  sharkomatic                          |       Owner:  ocean90
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  4.7
Component:  I18N                                 |     Version:  4.6
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing has-patch has-unit-    |     Focuses:
  tests                                          |  performance
-------------------------------------------------+-------------------------

Comment (by jrf):

 Thanks for the ping @ocean90 .

 I've just read through the thread, the slack logs and the patches.

 First (rough) idea which comes to my mind would be - what about adding a
 new `is_translation_available( $domain )` function/method which would keep
 a record in a static ?
 Something along the lines of:
 {{{#!php
 static $translation_located = array(
    ['domainA'] => false,
    ['domainB'] => 'path_to_translation_file_located',
 );
 }}}

 Some advantages of that:
 * Single responsibility principle for `is_textdomain_loaded()` which was
 implemented in [36538] does not get undone.
 * The new function again would have a single responsibility.
 * It would lower the complexity of the `_load_textdomain_just_in_time()`
 function.

 I'd need to look at all the relevant code in more detail to fine-tune the
 idea (and create a patch), but as a general solution direction, what do
 you think ?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37997#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list