-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
[i18n] RTL support #690
base: main
Are you sure you want to change the base?
[i18n] RTL support #690
Conversation
Doesn't work with `dir='rtl'` source: https://www.w3.org/International/geo/html-tech/tech-bidi.html#ri20030728.093644822
@@ -1168,7 +1168,6 @@ img.gallery-img { | |||
#showcase-page .showcase-intro h1 { | |||
font: italic 900 14.5vw "Montserrat", sans-serif; | |||
color: #ED225D; | |||
text-align: left; |
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.
👆 was not doing anything except breaking rtl 😄
I don't think there's currently plans to officially support additional languages other than the ones that are already live or are being worked on (ie. Korean and Hindi). Although this PR do add much of the things I would like to see on the site, we do have the policy of usually requiring an issue to be opened before a PR should be filed so that discussions about any particular features are hammered out before any work is done. I'm inclined to review this PR as is now but next time please do open an issue first. Thanks. |
Thanks for your comment @limzykenneth 🙌 If there is no plan for adding additional languages it is fine to close this PR, or just cherry-pick the needed changes. Maybe a more urgently needed change is to update the i18n doc with this policy before someone else starts translation for another language. |
@sepans Translation of the website is always welcomed, the only difference is whether a language is officially supported or not. An officially supported language will be listed on p5js.org while an unoffical one can be hosted by the translator wherever they wish. The i18n documentation aims to make the technical aspect of the translation clear and any suggestion of new official translations should follow the PR workflow documented here. |
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.
Some questions inline
Gruntfile.js
Outdated
@@ -81,6 +81,10 @@ module.exports = function(grunt) { | |||
assemble: { | |||
pages: { | |||
options: { | |||
rtl: function() { | |||
var rtlLangs = ['ar', 'fa', 'he', 'ur']; |
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.
Instead of listing all these languages here, can this just be a blank array and whenever a rtl language is added the translator can add the appropriate language code themselves?
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.
Yes totally. I feel var rtlLangs = ['ar', 'fa', 'he', 'ur']
is more self-documenting whereas var rtlLangs = []
is a bit of mystery why we lookup inside an empty list (assuming this doesn't affect performance since it is just a build time script)
And again we need to document this somewhere etc, but your call!
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.
We can expand on the contributor docs to include a section about RTL languages. Some line comments can be added here as well if you feel that just leaving it as an empty array is potentially confusing. Performance won't be a concern in any case here.
|
||
/* ======= Right-to-left modifications ======== */ | ||
|
||
html.rtl #lockup { |
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.
Can the selector be selecting the lang
attribute on the html tag instead of using a class on the tag?
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.
Yes that is possible. The downside is that for each new rtl language a lang
item needs to be added (and possibly someone spending some time to figure it out and/or documenting it). To me, rtl
class seems to be a small reasonable abstraction to cover them all.
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.
I would like to try out just using the lang
attribute for now, perhaps somewhere down the line we can look into automating the build to handle some of the details that needs to be added manually for now.
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.
Well, what language should I put there? I can arbitrarily add either lang(fa)
or lang(he)
, or all of them but in the above comment you suggested removing them all from the Gruntfile.js
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.
lang(fa)
for now would be fine, do add a line comment about what the function of it is just above.
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.
Sorry about the delay. I removed elements from rtlLangs
array as you suggested, but as for adding :lang(fa)
I think it is exactly opposite of what I did for rtlLangs
: adding code specific to a language that is not supported yet.
And also it gets ugly as we eventually add multiple rtl languages and chain css for all the language.
Thanks for the explanation. I still argue for adding that 'official languages' to the i18n document because I personally could have translated a lot of more examples instead of translating the homepage if I knew that. Maybe an RFC if a better place to have this discussion. |
@sepans Would you like to submit a modification to the translation docs? Only thing to keep in mind is that while we may not officially support some languages at the moment, any translation effort is always welcomed. |
Fixes: Support for Right-to-left languages (Persian, Arabic, Hebrew, Urdu etc.)
Changes (in 4 commits so review by commit is easier):
rtl
support: processing/p5.js-website@b65a373 (Mirrors the page for right to left languages)rtl
parameter toGruntfile
rtl
addsdir='rtl'
to<html>
tag.rtl
class to<html>
tag (Not ideal but better than restructuring the entire page)float: right
as it breaks rtl: processing/p5.js-website@7360072sidebar
to layout processing/p5.js-website@6da4690The sidebar on the homepage was inside a
flex
container and it was working fine but on the other pages it was not. I had to addflex
to the top container on every page but instead of that took the opportunity and moved the{{> sidebar }}
to the layout and addedflex
to the container in the layout to make the templates dryer.The diff looks large but the change was mechanical running a regex like:
Screenshots
more screenshots
Mobile
Note:
I am also working on Persian translation but decided to do 2 separate PRs to make the review easier for you. So this PR does not include
fa.yml
etc and the screenshots above with Persian text in them are just for demonstration. This PR should not cause any change to the website.Testing: I tried to check all the pages on different screen sizes and browsers but I might have missed a page since I don't know my way around the website very well.