material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[CollapsingToolbarLayout] End punctuation marks in LTR text are incorrectly positioned in RTL mode

Open pubiqq opened this issue 2 years ago • 10 comments

Description:

  • "Force RTL layout direction" -> ON
  • Open "TopAppBarCollapsingMultilineDemoFragment" demo (Material Catalog app)
  • Pay attention to the full stop position.

Expected behavior: The full stop should be at the end of the sentence.

Actual behavior: The full stop is at the beginning of the third line:

Material Library version: 1.7.0-alpha03 Device: Pixel 4a 5G (API 32)

pubiqq avatar Jul 18 '22 00:07 pubiqq

Hi @pubiqq, I think the Force RTL layout direction developer option should only be used to test out the alignment of Views within their parent ViewGroups, as opposed to content within Views. This is because Force RTL layout direction doesn't actually change the locale / internationalization, as opposed to using string translations and changing the device language, which is a more valid test.

Closing this for now but feel free to provide any more information.

dsn5ft avatar Jul 26 '22 23:07 dsn5ft

Well… okay, here's a more "valid" test (Device language: Persian (Iran)):

pubiqq avatar Jul 27 '22 13:07 pubiqq

That's still not a valid setup because the strings in the catalog are not translated.

dsn5ft avatar Jul 27 '22 13:07 dsn5ft

So that's the point, I want the LTR text to be displayed correctly in RTL environment. Like, if I have a store called "Yummy!", I don't want its name to turn into "!Yummy" for RTL locale.

pubiqq avatar Jul 27 '22 13:07 pubiqq

Gotcha, so you found a way to do that without breaking the overall alignment?

dsn5ft avatar Jul 27 '22 13:07 dsn5ft

Maybe. I don't know what the original problem was, so it's hard to say (description of 841f229 didn't clarify anything to me).

pubiqq avatar Jul 27 '22 14:07 pubiqq

It's basically the following, for short LTR text with an RTL device config, we want the alignment to be on the right:

Before https://github.com/material-components/material-components-android/commit/841f2295921b4eed8bd16bb72b28d4ef7ca7cfa5 After https://github.com/material-components/material-components-android/commit/841f2295921b4eed8bd16bb72b28d4ef7ca7cfa5
image image

Can you test that case with your latest changes, and also update your PR to have Before vs After screenshots of the Collapsing Toolbar demos?

dsn5ft avatar Jul 27 '22 14:07 dsn5ft

Yeah, sure:

Before PR#2831 After PR#2831

pubiqq avatar Jul 27 '22 16:07 pubiqq

Sorry can you also post an After video with the device language set to an RTL language? (not just Force RTL)

dsn5ft avatar Jul 27 '22 17:07 dsn5ft

Before PR#2831 After PR#2831

pubiqq avatar Jul 27 '22 17:07 pubiqq