Skip to content

Commit

Permalink
Notifications: Use profile locale to match menu language (#38871)
Browse files Browse the repository at this point in the history
* Notifications: Use profile locale instead of site locale

* changelog

* Locale in ISO 639-1
  • Loading branch information
lupus2k authored Aug 27, 2024
1 parent f22c8d7 commit 9a9838f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Notifications: Use profile locale to match menu language
10 changes: 5 additions & 5 deletions projects/plugins/jetpack/modules/notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function admin_bar_menu() {
return;
}

$wpcom_locale = get_locale();
$user_locale = get_user_locale();

if ( ! class_exists( 'GP_Locales' ) ) {
if ( defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) && file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
Expand All @@ -182,9 +182,9 @@ public function admin_bar_menu() {
}

if ( class_exists( 'GP_Locales' ) ) {
$wpcom_locale_object = GP_Locales::by_field( 'wp_locale', $wpcom_locale );
if ( $wpcom_locale_object instanceof GP_Locale ) {
$wpcom_locale = $wpcom_locale_object->slug;
$jetpack_locale_object = GP_Locales::by_field( 'slug', $user_locale );
if ( $jetpack_locale_object instanceof GP_Locale ) {
$user_locale = $jetpack_locale_object->slug;
}
}

Expand All @@ -196,7 +196,7 @@ public function admin_bar_menu() {
'id' => 'notes',
'title' => $title,
'meta' => array(
'html' => '<div id="wpnt-notes-panel2" class="intrinsic-ignore" style="display:none" lang="' . esc_attr( $wpcom_locale ) . '" dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"><div class="wpnt-notes-panel-header"><span class="wpnt-notes-header">' . __( 'Notifications', 'jetpack' ) . '</span><span class="wpnt-notes-panel-link"></span></div></div>' . $third_party_cookie_check_iframe,
'html' => '<div id="wpnt-notes-panel2" class="intrinsic-ignore" style="display:none" lang="' . esc_attr( strtolower( substr( $user_locale, 0, 2 ) ) ) . '" dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"><div class="wpnt-notes-panel-header"><span class="wpnt-notes-header">' . __( 'Notifications', 'jetpack' ) . '</span><span class="wpnt-notes-panel-link"></span></div></div>' . $third_party_cookie_check_iframe,
'class' => 'menupop',
),
'parent' => 'top-secondary',
Expand Down

0 comments on commit 9a9838f

Please sign in to comment.