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

WordPress Trac noreply at wordpress.org
Thu Oct 11 18:24:54 UTC 2018


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

Comment (by TimothyBlynJacobs):

 @leewillis77 Could you give this latest patch a try?

 I loaded the proxy files in `wp_load_translations_early` and also adjusted
 the load order of the proxy files to be loaded right after the rest of the
 locale files are loaded in `wp-settings.php`.

 I also fixed an issue with `wp_die()` which casted everything to a string,
 but WP_Error is an allowed parameter type. For safety, I just changed the
 string casting to only take place on `WP_String_Proxy` objects.

 ----

 Side note. This doesn't entirely fix the issue for the REST API locale
 ticket because string proxies that have already been evaluated will not
 have their evaluation dropped when the locale switches.

 What do people think about adding a `$locale` property to the string proxy
 and changing the `result()` conditional to: ` null === $this->result ||
 get_locale() !== $this->locale`? I think that should be more memory
 efficient than allocating an array to store a map of locales => evaluated
 strings.

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


More information about the wp-trac mailing list