Skip to content

Commit

Permalink
Remove user locale and use current locale
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Jul 26, 2024
1 parent b368269 commit 27c7e4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
13 changes: 4 additions & 9 deletions lib/compat/wordpress-6.7/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ function gutenberg_get_block_editor_settings_6_7( $settings ) {
}
}

$settings['locale'] = array(
'site' => array(
'lang' => $current_site_locale,
'isRTL' => $current_site_is_rtl,
),
'user' => array(
'lang' => $current_user_locale,
'isRTL' => $current_user_is_rtl,
),
// @TODO confirm if `lang` just needs to be added to the `/wp/v2/settings` response`.
$settings['siteLocale'] = array(
'lang' => $current_site_locale,
'isRTL' => $current_site_is_rtl,
);

return $settings;
Expand Down
11 changes: 5 additions & 6 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useEffect,
useRef,
} from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { __, isRTL } from '@wordpress/i18n';
import {
useResizeObserver,
useMergeRefs,
Expand Down Expand Up @@ -64,7 +64,7 @@ function bubbleEvent( event, Constructor, frame ) {
}

/**
* Bubbles some event types (keydown, keypress, and dragover) to parent document
* Bubbles some event types (keydown, keypress, and dragover) to parent
* document to ensure that the keyboard shortcuts and drag and drop work.
*
* Ideally, we should remove event bubbling in the future. Keyboard shortcuts
Expand Down Expand Up @@ -112,15 +112,14 @@ function Iframe( {
title = __( 'Editor canvas' ),
...props
} ) {
const { resolvedAssets, isPreviewMode, siteLocale, userLocale } = useSelect(
const { resolvedAssets, isPreviewMode, siteLocale } = useSelect(
( select ) => {
const { getSettings } = select( blockEditorStore );
const settings = getSettings();
return {
resolvedAssets: settings.__unstableResolvedAssets,
isPreviewMode: settings.__unstableIsPreviewMode,
siteLocale: settings.locale?.site,
userLocale: settings.locale?.user,
siteLocale: settings.siteLocale,
};
},
[]
Expand Down Expand Up @@ -288,7 +287,7 @@ function Iframe( {
and should therefore match the editor UI's directionality.
*/
.block-editor-block-list__layout .components-placeholder {
direction: ${ userLocale?.isRTL ? 'rtl' : 'ltr' };
direction: ${ isRTL() ? 'rtl' : 'ltr' };
}
</style>
${ styles }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const BLOCK_EDITOR_SETTINGS = [
'postsPerPage',
'readOnly',
'sectionRootClientId',
'siteLocale',
'styles',
'titlePlaceholder',
'supportsLayout',
Expand Down

0 comments on commit 27c7e4a

Please sign in to comment.