[wp-trac] [WordPress Trac] #26511: Introduce a locale-switching function
WordPress Trac
noreply at wordpress.org
Wed Oct 26 15:36:00 UTC 2016
#26511: Introduce a locale-switching function
-------------------------------------------------+-------------------------
Reporter: johnbillion | Owner: swissspidy
Type: feature request | Status: closed
Priority: high | Milestone: 4.7
Component: I18N | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests needs-dev- | Focuses:
note commit |
-------------------------------------------------+-------------------------
Changes (by ocean90):
* status: accepted => closed
* resolution: => fixed
Comment:
In [changeset:"38961"]:
{{{
#!CommitTicketReference repository="" revision="38961"
I18N: Introduce a locale-switching function.
With the introduction of user-specific languages in [38705] it's necessary
to be able to switch translations on the fly. For example emails should be
sent in the language of the recipient and not the one of the current user.
This introduces a new `WP_Locale_Switcher` class which is used for
switching locales and translations. It holds the stack of locales whenever
`switch_to_locale( $locale )` is called. With `restore_previous_locale()`
you can restore the previous locale. `restore_current_locale()` empties
the stack and sets the locale back to the initial value.
`switch_to_locale()` is added to most of core's email functions, either
with the value of `get_locale()` (site language) or `get_user_locale()`
(user language with fallback to site language).
Props yoavf, tfrommen, swissspidy, pbearne, ocean90.
See #29783.
Fixes #26511.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26511#comment:103>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list