cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x] add rtl styles for control panel

Open peimn opened this issue 1 year ago • 6 comments

This PR will add rtl styles for RTL languages like Arabic, Persian, Hebrew...

peimn avatar Feb 01 '24 19:02 peimn

Amazing. We were about to do this ourselves.

jasonvarga avatar Feb 01 '24 19:02 jasonvarga

Dude!

Standing Ovation

jackmcdade avatar Feb 01 '24 19:02 jackmcdade

You're welcome 🤗. I like Statamic and would suggest it to whole world in any language and any region...

peimn avatar Feb 01 '24 20:02 peimn

Blush

jackmcdade avatar Feb 01 '24 20:02 jackmcdade

Make me think about at least one fieldtype (range) where you can prepend and append a text and I think RTL language can have a hard time with this, doesn't it?

Capture d’écran 2024-02-17 à 13 46 09

ebeauchamps avatar Feb 17 '24 12:02 ebeauchamps

Maybe the translation can be changed if it's a RTL language. e.g. instead of saying beginning (left-side) it would be translated to beginning (right-side).

jasonvarga avatar Feb 20 '24 16:02 jasonvarga

Hey @peimn why did slug fields need to be ltr?

jasonvarga avatar Mar 08 '24 20:03 jasonvarga

@jasonvarga It is common for slugs to be written in Latin words, and we prefer to write it in Latin words as non-Latin writers. It is easy to remember and write. Furthermore, Statamic itself converts non-latin words to Latin. Therefore, I decided to make it a ltr.

peimn avatar Mar 08 '24 20:03 peimn

Okay I will leave it how you had it then. Thanks!

jasonvarga avatar Mar 08 '24 20:03 jasonvarga

I've made a change to how the text direction of the CP is decided.

You had it so that it depends on the selected site. I've changed it so that it's based on the configured locale or preference. If you have configured a language that should be RTL (like Arabic or Hebrew), it will be RTL.

Similar to #9452, I didn't feel it was right that the whole control panel changed depending on what site you were targeting. If I speak one language, and I've set my preference to a specific language, I don't want the whole CP to change.

However I do think it's a good idea to change the direction of the fields inside the publish forms when you're editing an entry in a specific site. This behavior is consistent with how Craft CMS works, and they do a great job with localization and RTL support. See in this screenshot, everything is in English/LTR (my preferred language) except the field (I only configured one) which is RTL because the current entry is Arabic.

CleanShot 2024-03-08 at 16 52 59

We can adjust that behavior in another PR though. There's so much in this one already. (It's fantastic!)

jasonvarga avatar Mar 08 '24 22:03 jasonvarga

I haven't work with Craft CMS though I get the idea from your words. in #9452 we first had a look for prefered language and if user hadn't set any then switch would be done. But you are right, if we could apply language prefered direction to input fields and editors, it will suit to user needs.

peimn avatar Mar 09 '24 05:03 peimn

@peimn Do you have translation files for Persian?

Everything seems to be ready to merge but I'm just curious what you are actually using since we don't include any RTL languages.

jasonvarga avatar Mar 11 '24 15:03 jasonvarga

@jasonvarga yes I've, and I was waiting for this request to be merged then request to merge Persian language. I will send it in a minute.

peimn avatar Mar 11 '24 17:03 peimn

@jasonvarga #9707 now has Persian translation. Sorry it took a time.

peimn avatar Mar 11 '24 21:03 peimn