[wp-trac] [WordPress Trac] #59695: determine_locale ignores get_user_locale() in front end

WordPress Trac noreply at wordpress.org
Fri Oct 20 12:44:13 UTC 2023


#59695: determine_locale ignores get_user_locale() in front end
----------------------------+-----------------------------
 Reporter:  pentatonicfunk  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  I18N            |    Version:  6.3.2
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 It works in wp-admin (is_admin) but does not work as expected in front-end

 {{{#!php
 <?php

 /**
  * Setup Site language = en_US
  * User language = fr_FR
  */
 add_action( 'in_admin_footer', '_print_locale');
 add_action( 'wp_footer', '_print_locale');

 function _print_locale(){
         ?>
         <div style="text-align: center;">
                 <h3>get_user_locale: <?php echo esc_html(
 get_user_locale() ); ?> </h3> // in both WP-admin and front end it prints
 fr_FR
                 <h3>determine_locale: <?php echo esc_html(
 determine_locale() ); ?> </h3> // in WP-admin it prints fr_FR, but in
 front end it prints en_US
         </div>
         <?php
 }

 }}}


 the `determine_locale` it self has `is_admin()` logic, so maybe there are
 limitations / caveats of why this purposely skipped in front end ?

 there are some discussions here that maybe related:
 https://core.trac.wordpress.org/ticket/29783

 But i look at it as inconsistency, due to WP-admin-bar, it potentially
 have different language being used, even though the component looks
 identical between viewed in wp-admin or in front end.

 In general i would expect when i set my language settings as X, i would
 see X in the whole site when im logged in. Except user-generated content
 of course.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59695>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list