[wp-trac] [WordPress Trac] #46230: Calling `switch_to_locale()` fails to load plugin translations on subsequent calls
WordPress Trac
noreply at wordpress.org
Mon Feb 11 04:50:27 UTC 2019
#46230: Calling `switch_to_locale()` fails to load plugin translations on
subsequent calls
--------------------------+-----------------------------
Reporter: dd32 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In short, calling `switch_to_locale()` followed by
`restore_previous_locale()` followed by `switch_to_locale()` fails to
reload plugin text-domain strings. It appears to work as expected with the
`default` text-domain however.
An example in code (see unit test attached).
{{{
$english_text_expected = __( 'Testing', 'textdomain' );
// returns 'Testing'
switch_to_locale( 'de_DE' );
$german_expected = __( 'Testing', 'textdomain' );
// returns 'Testen'
restore_previous_locale(); // Reset to English.
switch_to_locale( 'de_DE' );
$german_expected_again = __( 'Testing', 'textdomain' );
// returns 'Testing' - No translation?
restore_previous_locale();
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46230>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list