[wp-trac] [WordPress Trac] #41305: Add lazily evaluated translations
WordPress Trac
noreply at wordpress.org
Fri Oct 12 05:47:24 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):
Ignore the unit tests comment, was an issue with my local setup.
However, looking at the issue with string proxy evaluations. Following an
approach like I describe isn't workable due to #37997.
Braindump of possible solutions:
1. Always retrieve a fresh value if `is_locale_switched()`. This would
lose a lot of performance gains when doing a REST API request with the
locale set.
2. Move storage to a static array. When locale is switched, empty out the
static array. Would require a new protected `$id` property to use as a key
could be based off of the text and any other modifiers, or just a static
counter should work. When the object is `__destruct`ed it could remove its
entry from the static array.
3. Similar as 2, but change the storage format to be first keyed by
locale, then keyed by the proxy ID. Store the current locale as a static
property. When the locale changes, change the static locale property. This
could have a negative memory impact if switching to a lot of different
locales during a request. For instance, when sending out an email to
multiple different users. However, I'd imagine that not many different
strings would be evaluated in a case like this.
Other thoughts?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41305#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list