-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block editor canvas should use site language and language direction #52777
Comments
Hi, |
I still have a same problem with WordPress 6.3 |
I thought this was a new bug with the iframe editor, but #44863 mentions needing to have (post) content in the site language when the profile language is different. I did not find a WordPress version that showed site (or post) content in the site language when the profile was different. Did it ever work? |
2024-07-07.02-51-02.mp4 |
In this Example your Profile language same as your Site language means your profile and your Site language are same. |
Apologies, thanks for setting me straight. So, is the following an accurate summary?
|
Yes, for example, in my case I build Arabic and Kurdish websites and they are both RTL languages and my profile is always in English When site language is Kurdish (RTL) should the Theme language be Kurdish too and the Editor canvas should shows from right to left (RTL) the Admin dashboard and The Editor Dashboard should match the profile language |
I can reproduce now, thanks! The TL;DR is that the iframed editor needs access to the site locale to set What's happening now is that, if a user locale is set in I had a quick look and there are a few things to investigate here. The editor iframeThe editor iframe assumes that the editor language direction is the same as the parent frame language direction, and copies the attribute to the iframed html element:
If the user locale is However, the editor iframe doesn't know what the site locale is, because it's looking at the parent frame, which is set to the user locale of Editor settingsWe could fetch the right values from the editor iframe via the settings... the interesting task will be returning accurate values for language direction. Here's what I'm seeing: In the editor, the "current" locale is set to the user locale. So, That means is_rtl() looks at the current, global locale. What we want is the site locale however, and I'm not yet sure how to grab that. There's probably a way, I just ran out of time. // Site locale
get_locale(); // ar
// User locale (current)
get_user_locale(); // en_US
// Current site language dir
is_rtl(); // ltr from the current locale.
// Current user language dir
?? // How to get this?
CSSI'm not sure yet, but I'm also wondering if different CSS needs to be loaded if the iframed editor's language direction differs from the parent. I'd wager "yes", but I haven't looked into it. |
You'll need to switch to the locale first to find out. e.g. $switched_locale = switch_to_locale( get_locale() );
$is_rtl = is_rtl();
if ( $is_switched ) {
if ( $switched_locale ) {
restore_previous_locale();
}
I'd imagine you need to load all the blocks' RTL stylesheets. Maybe some different translations too. |
I updated to 6.6.1 but still there is same issue Environment
|
@OmerQadirFM This is expected, as this issue is still open :-) |
Thanks @swissspidy - I'd totally overlooked I have a proof of concept: It probably raises more questions than answers, most notably how to handle block CSS and block placeholder text direction. There are without doubt many more that I've not thought of. |
A bit of history: a bug was reported about similar behaviour in the classic editor: |
@ramonjd just checking in to see if we are still aiming to get this completed for 6.7, or whether it should be punted to 6.8. Thanks! |
@ndiego Thanks for the ping. Unfortunately, I won't have time in the immediate future to take this further. I've punted it. The status is that #63883 adds the correct lang attributes to the editor canvas, but more works is required so that the editor canvas is translated in the site language where the surrounding editor/admin language differs. |
Thanks for the update! |
Description
when I'm making a Kurdish or Arabic website, my website shows from LTR in Gutenberg interface but when I visit my website it shows RTL, My user profile language is English and my website language is Kurdish, it is supposed to always shows RTL.
Step-by-step reproduction instructions
in Gutenberg interface
Change user profile language to English
Change website language to Kurdish or Arabic
then go to Appearance > Editor and you will see the issue
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: