Skip to content

RTL support - #2263

Merged
WorldLanguages merged 23 commits into
ScratchAddons:masterfrom
mxmou:rtl1
May 22, 2021
Merged

RTL support#2263
WorldLanguages merged 23 commits into
ScratchAddons:masterfrom
mxmou:rtl1

Conversation

@mxmou

@mxmou mxmou commented Apr 22, 2021

Copy link
Copy Markdown
Member

Resolves

Resolves #1844
Resolves #1877

Changes

Adds support for right-to-left scripts to the settings page, popup and editor addons. Website addons don't need it because the website itself doesn't have proper RTL support. Notes:

  • Untranslated strings sometimes display weirdly. Untranslated descriptions on the settings page are truncated incorrectly: the end of the description is visible instead of the beginning.
  • Comments in the messaging popup are always left-to-right to make sure that they're displayed the same way as on Scratch.
  • Quite a few changes to the hide-flyout addon were necessary, so I also fixed a few bugs.

Reason for changes

#1844

Tests

Tested by changing the browser and Scratch language.

@mxmou
mxmou requested a review from WorldLanguages as a code owner April 22, 2021 19:54
Comment thread popups/scratch-messaging/popup.css Outdated
@WorldLanguages

Copy link
Copy Markdown
Member

@mxmou King 👑
Was thinking on the bus about this, I arrive home and 2 hours later this PR appears out of nowhere 😂

@mxmou mxmou changed the title RTL support RTL support and hide-flyout changes Apr 23, 2021
@apple502j

Copy link
Copy Markdown
Member

What happens when someone enables editor-stage-left?

@apple502j apple502j added priority: 4 Low priority. Includes minor bugs and less important features scope: addon Related to one or multiple addons scope: l10n All about localization/internationalization scope: webpages Related to the web pages (settings page, pop-up, etc) labels Apr 24, 2021
@mxmou

mxmou commented Apr 24, 2021

Copy link
Copy Markdown
Member Author

@apple502j It moves the stage to the right.

@WorldLanguages

Copy link
Copy Markdown
Member

Website addons don't need it because the website itself doesn't have proper RTL support.

Oh wow.

Untranslated strings sometimes display weirdly. Untranslated descriptions on the settings page are truncated incorrectly: the end of the description is visible instead of the beginning.

We probably don't want to merge this before those are solved - for RTL users, our settings page probably got worse, not better, at the current state of this PR. We don't have complete translations for Arabic or Hebrew yet anyway (this is a bit of a mouse and cat game anyway, I know). So I guess that for the settings page, we'll not only have to support LTR and RTL, but RTL with LTR translation fallbacks as well, which kinda hurts, but is strictly needed, at least for now.

  • Quite a few changes to the hide-flyout addon were necessary, so I also fixed a few bugs.

Your changes add new calls to addon.tab.waitForElement, so we'll need to coordinate efforts with #2268

@WorldLanguages

Copy link
Copy Markdown
Member

What happens when someone enables editor-stage-left?

@apple502j If you want, this would be a good moment to add support for translator notes inside addons-l10n. editor-stage-left doesn't have a file on there (all of its strings are in addon.json), but we could create one that stores the notes reminding Arabic/Hebrew translators that they need to use "right" instead of "left" in both the addon name and description.

@mxmou

mxmou commented Apr 28, 2021

Copy link
Copy Markdown
Member Author

Is displaying punctuation like this wrong?
image

@WorldLanguages

Copy link
Copy Markdown
Member

Is displaying punctuation like this wrong?
image

If it's easy to fix, do it. If not, create an issue and we'll throw it at the backlog :P

@mxmou

mxmou commented Apr 28, 2021

Copy link
Copy Markdown
Member Author

@WorldLanguages It could be fixed by adding dir="auto" to all elements with this issue, but I'm not sure if that's a very good idea.

@WorldLanguages

Copy link
Copy Markdown
Member

@mxmou Why is it a bad idea?

@mxmou

mxmou commented Apr 28, 2021

Copy link
Copy Markdown
Member Author

@WorldLanguages When a new element with punctuation is added, it would also need the attribute.

@WorldLanguages

Copy link
Copy Markdown
Member

Well, that's not ideal, but what are the alternatives?

@mxmou

mxmou commented Apr 28, 2021

Copy link
Copy Markdown
Member Author

Well, that's not ideal, but what are the alternatives?

I don't know any.

@WorldLanguages

Copy link
Copy Markdown
Member

@mxmou

  • If you're ok with this, I'd prefer merging this but with RTL off for our own webpages. Arabic and Hebrew are 10% and 0% translated respectively, and it doesn't make sense to ship RTL webpages yet. Of course we can keep the HTML/JS/CSS changes, but the <body> element should have dir="ltr" for all languages for now (you can hardcore this on vue.direction method). Apple and I will try to make a few changes on how translation works soon (stuff has changed since v1.4.0) and specially try to get consistent Arabic/Hebrew translators to make this worth it
  • About dir="auto", we should use that in the editor to make sure punctuation isn't messed up. We don't need to care that much about using it in our own webpages for now, because of point above
  • Weird scrollbars:
    image

@mxmou

mxmou commented May 7, 2021

Copy link
Copy Markdown
Member Author

Could we split hide-flyout changes into another PR?

Maybe I could move all changes to hide-flyout, including the ones that add RTL support? They're bigger than changes to other addons.

@WorldLanguages

WorldLanguages commented May 7, 2021

Copy link
Copy Markdown
Member

Yeah you can move all changes from hide-flyout or just some, you decide

@WorldLanguages

Copy link
Copy Markdown
Member

@mxmou ?

@mxmou

mxmou commented May 11, 2021

Copy link
Copy Markdown
Member Author

@WorldLanguages I think I'll work on this later today.

@mxmou

mxmou commented May 12, 2021

Copy link
Copy Markdown
Member Author

Why did Prettier make changes to unrelated files?

@WorldLanguages

WorldLanguages commented May 12, 2021

Copy link
Copy Markdown
Member

Why did Prettier make changes to unrelated files?

It does that sometimes lol ¯\(ツ)

@mxmou

mxmou commented May 14, 2021

Copy link
Copy Markdown
Member Author

I think this PR is now finished. Note that it adds some uses of inset-inline, which is only supported in Chrome 87+.

@WorldLanguages

Copy link
Copy Markdown
Member

Do not merge yet

@WorldLanguages

Copy link
Copy Markdown
Member

I think this PR is now finished. Note that it adds some uses of inset-inline, which is only supported in Chrome 87+.

TODO: is this ok, alternatives? 🤔

@mxmou

mxmou commented May 14, 2021

Copy link
Copy Markdown
Member Author

I think this PR is now finished. Note that it adds some uses of inset-inline, which is only supported in Chrome 87+.

TODO: is this ok, alternatives? 🤔

If it isn't, the best alternative is

.something {
  left: 10px;
}
[dir="rtl"] .something {
  left: 0;
  right: 10px;
}

Comment thread webpages/settings/style.css Outdated
@WorldLanguages

WorldLanguages commented May 15, 2021

Copy link
Copy Markdown
Member

We currently want core to be functional in Chrome 80+ and Firefox 74+ (both released ~1 year from now)

The CSS properties I found used here that are not supported in those browsers are:

  • inset-inline-*: Chrome 87+, Firefox OK
  • border-[start/end]-[start/end]-radius: Chrome 89+, Firefox OK

I guess a good compromise we could do is officially support RTL only for Chrome 89+
And in order to support Chrome 80+, we could continue to set mapped physical properties (example: border-top-left-radius) but above the new better properties (example: border-start-start-radius), so that everything looks the same in Chrome < 88 for LTR users.

For example:

el {
  inset-inline-end: 25px;
}

would become:

el {
  right: 25px;
  inset-inline-end: 25px;
}

Which would now support LTR for Chrome 80+ and all Firefox versions, as well as RTL in Chrome 89+ and all Firefox versions.

@mxmou What do you think? It will be easy to migrate when our minimum browser version requirements change (all we need to do is remove properties) and there's no need to do [dir="rtl"] selectors

Note that I'm talking exclusively about extension core CSS. Not addon CSS (which uses [dir="rtl"] selectors to be consistent with Scratch itself anyway)

@mxmou

mxmou commented May 16, 2021

Copy link
Copy Markdown
Member Author

@WorldLanguages This would work, but I'm not sure if having different version requirements for LTR and RTL layouts makes sense. If we want core to work in a certain browser version, it should probably work with that version regardless of the language.

@WorldLanguages

Copy link
Copy Markdown
Member

@mxmou What do you suggest then? 🤔 We haven't supported RTL until now, so it feels like a good compromise to avoid separate [dir="rtl"] selectors (which will be able to be removed in a few months anyway) by only making RTL available in newer Chrome versions, which most of our users have anyway
I considered using __MSG_@@bidi_start_edge__ and __MSG_@@bidi_end_edge__ in the middle of the name of CSS properties, which would probably work, but it would use the browser configuration, not the dir attribute of the root element we can determine on runtime.

@mxmou

mxmou commented May 17, 2021

Copy link
Copy Markdown
Member Author

@WorldLanguages I guess it would work, I just don't think there's anything wrong with adding [dir="rtl"] selectors and removing them later.

@WorldLanguages

Copy link
Copy Markdown
Member

Then do that I guess :P

@mxmou mxmou changed the title RTL support and hide-flyout changes RTL support May 22, 2021
@WorldLanguages

Copy link
Copy Markdown
Member

Solve conflicts and merge?

@WorldLanguages
WorldLanguages merged commit 2bfd254 into ScratchAddons:master May 22, 2021
@mxmou
mxmou deleted the rtl1 branch June 6, 2021 14:03
@cobaltt7

Copy link
Copy Markdown
Contributor
  • If you're ok with this, I'd prefer merging this but with RTL off for our own webpages. Arabic and Hebrew are 10% and 0% translated respectively, and it doesn't make sense to ship RTL webpages yet. Of course we can keep the HTML/JS/CSS changes, but the element should have dir="ltr" for all languages for now (you can hardcore this on vue.direction method). Apple and I will try to make a few changes on how translation works soon (stuff has changed since v1.4.0) and specially try to get consistent Arabic/Hebrew translators to make this worth it

@WorldLanguages 17 months later, Arabic and Hebrew are 54% and 46% translated respectively. I think we forgot to enable this :P

@WorldLanguages

Copy link
Copy Markdown
Member

@RedGuy12 Those languages didn't hit the necessary threshold for them to be included. See https://github.com/ScratchAddons/ScratchAddons/tree/master/_locales

But we should pay close attention, they might appear soon automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: 4 Low priority. Includes minor bugs and less important features scope: addon Related to one or multiple addons scope: l10n All about localization/internationalization scope: webpages Related to the web pages (settings page, pop-up, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Palette is initially visible when auto-hide block palette is enabled Add RTL support

6 participants