-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Right-to-left CSS #6822
Right-to-left CSS #6822
Conversation
I looked into adding an RTL-CSS plugin for Gulp to automate this. The existing plugin creates an alternate .rtl.css file, and changes which CSS file is loaded... I feel like it would be difficult to swap CSS files based on language |
@mapmeld first, thanks a bunch for this! RTL support is important but we've neglected it, unfortunately. Would you ming rebasing this on the latest |
@whymarrh Thanks! Rebased so it lines up with current develop branch |
@whymarrh also - I started making a smaller branch which would use gulp-rtlcss, but I'm not sure how to switch between index.css and index-rtl.css in the way CSS works in MetaMask: https://github.com/mapmeld/metamask-extension/tree/rtlcss_module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two quick comments, otherwise these code changes look pretty good to me
@whymarrh I agree with the changes 👍 |
We might be better off using predefined messages instead of taking this approach. These predefined messages can be referenced directly from CSS, and can be obtained in JavaScript using The internationalization API appears to be well supported on the browsers we support, and it should make this easier to maintain going forward. We could also reference these predefined messages directly from the manifest, letting us use rlt-specific or locale-specific HTML if need be later on. |
Where would we use the predefined messages? In the CSS? Or in the HTML on some attr? |
I don't believe these messages work in HTML. They're only accessible in JavaScript via For example, the For most of these CSS changes, we could use My impression from reading the MDN and the Chrome extension docs is that this is the approach they're recommending for internationalizing extensions. I'm not entirely clear on what this gains us over the current state of this PR though. Getting rid of that hard-coded list of rtl locales seems like a clear win, and an easy change to make, but the CSS changes would be quite substantial. Maybe the only benefit would be in having less CSS rules (leading to marginally faster parsing+execution)? Who knows. I don't feel strongly about it at this point anyway. I thought it was an interesting solution though. |
This might be the ideal way to set dir="ltr" or "rtl", rather than having JS figuring it out from our locale. But I wonder if it updates immediately when we change the MetaMask preferred language? If there's interest I could test this. |
Excellent point - it looks like my suggestions wouldn't work after all. The Oh well. Disregard my previous suggestions 😄. Maybe we can try that sometime in the future. |
So I guess the last consideration is whether to go with this, or something along the lines of your There's a lot to like about the RTLCSS approach. It seems like it'd be easier to maintain. I'll experiment tomorrow with switching between the two CSS files. I want to make sure we minimize the performance impact. Assuming we can get that to work, I think that would be a better solution. |
This ended up being a bit more challenging than anticipated. I have something that sorta works here, but it isn't quite finished yet. I'll try to find time to finish it and/or explain it in the next few days. |
@Gudahtt I re-synced with the develop branch. If you want to talk about the branch on Gitter, I sent you a message there |
I believe I've gotten the stylesheet switching to work: https://github.com/Gudahtt/metamask-extension/tree/rtlcss_module That branch is based upon your |
Replacing with a switching stylesheet PR in a moment |
Long time in the works, and finally here - right-to-left CSS (and a little JS) for MetaMask #5436
I recently met a blockchain teacher at Re-Coded's coworking space in Erbil, and he is interested in translating MetaMask into Persian (and maybe Kurdish later). On my side I offered to add RTL stylesheets. Here's what it looks like with the translation (which will be in a separate PR)
CSS notes:
[dir='rtl'] & { }
blocks , this means their internal changes (swapping left and right) happen only if an upper element has setdir="rtl"
direction: ltr;
to CSS; this will not change any current views but maintains consistency displaying token names, seed phrases, negative numbers, and other LTR contentJS notes:
dir="rtl"
ordir="auto"
to the top-level divdir="auto"
to a text field such as account name; this will accommodate typing LTR or RTL languages into that text field