[wp-trac] [WordPress Trac] #44937: Add _doing_it_wrong to load_plugin_textdomain
WordPress Trac
noreply at wordpress.org
Wed Oct 23 10:08:27 UTC 2024
#44937: Add _doing_it_wrong to load_plugin_textdomain
------------------------------------+-------------------------
Reporter: garrett-eclipse | Owner: swissspidy
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.7
Component: I18N | Version: 4.7
Severity: normal | Resolution: fixed
Keywords: has-patch has-dev-note | Focuses:
------------------------------------+-------------------------
Comment (by bobbingwide):
> The current user is normally set up in-between.
@swisspidy
It's still not clear to me which translations will be used when the site
has one locale defined and the logged in user has an override.
I wrote a tiny plugin to see if I got different results depending upon the
hook I was responding to.
{{{
//add_action( 'after_setup_theme', 'xast_after_setup_theme');
add_action( 'init', 'xast_init');
function xast_after_setup_theme() {
$cheque_colour = __( 'check color', 'xast');
bw_trace2( $cheque_colour, 'check color?', false);
}
function xast_init() {
$cheque_colour = __( 'cheque color', 'xast');
bw_trace2( $cheque_colour, 'cheque color?', false);
}
}}}
In my tests I was logged in with a user who had selected a different
Language to that defined for the Site Language.
Site language: bb_BB
User language: en_GB
Translations:
en_US: check color
en_GB: check colour
bb_BB: cehck cloor
en_US: cheque color
en_GB: cheque colour
bb_BB: cehuqe cloor
The output for the translation performed during `init` was `cehuqe color`.
I was expecting it to be `cheque colour`.
I toggled the hook and for `after_setup_theme` I got `cehck cloor`.
In neither case did I get the output in the current user's preferred
language.
In the dashboard I do get the expected results.
So now I am doubly confused
- Why don't I get my output in the user's preferred language?
- Why / how does it work in wp-admin?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44937#comment:57>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list