[wp-trac] [WordPress Trac] #41305: Add lazily evaluated translations

WordPress Trac noreply at wordpress.org
Thu Jan 31 17:26:12 UTC 2019


#41305: Add lazily evaluated translations
-------------------------------------------------+-------------------------
 Reporter:  schlessera                           |       Owner:
                                                 |  timothyblynjacobs
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.2
Component:  I18N                                 |     Version:  4.8
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch early dev-feedback needs-  |     Focuses:  rest-api,
  testing                                        |  performance
-------------------------------------------------+-------------------------

Comment (by TimothyBlynJacobs):

 I've added a patch that stores the translations in a central cache object
 so they can be changed if the locale switches.

 It doesn't bench as well, probably because of the additional property.
 This might be solvable with `spl_object_hash` since when the object is
 destructed, we clear out the value from the centralized cache, so there
 shouldn't be a risk of PHP reusing the same object handle. This would have
 to happen after the PHP version bump I think because SPL isn't currently
 required by core.

 {{{
 11.66620516777
 227,797,672
 }}}

 As an aside, now that we solved translations for REST requests
 differently, I'm not sure how needed the centralized cache busting is. It
 will make switching locales work better for plugins that don't re-register
 their translations when the locale changes. Without the centralized cache
 clearing, and just the lazy evaluation, if a translations wasn't actually
 evaluated ''until'' the locale is switched, then the translation would be
 incorrect for the rest of the request.

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


More information about the wp-trac mailing list