Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

[i18n] RTL support #690

wants to merge 5 commits into from

Conversation

sepans
Copy link
Member

@sepans sepans commented Apr 14, 2020

Fixes: Support for Right-to-left languages (Persian, Arabic, Hebrew, Urdu etc.)

Changes (in 4 commits so review by commit is easier):

  • Adds rtl support: processing/p5.js-website@b65a373 (Mirrors the page for right to left languages)
    • Adds rtl parameter to Gruntfile
    • Based on rtl adds dir='rtl' to <html> tag
    • Adds .rtl class to <html> tag (Not ideal but better than restructuring the entire page)
  • Slightly restructures homepage 'Hello' and search bar to avoid float: right as it breaks rtl: processing/p5.js-website@7360072
  • Some css overrides: processing/p5.js-website@23d0c46
  • Moved sidebar to layout processing/p5.js-website@6da4690
    The 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 add flex to the top container on every page but instead of that took the opportunity and moved the {{> sidebar }} to the layout and added flex to the container in the layout to make the templates dryer.
    The diff looks large but the change was mechanical running a regex like:
<div id="([a-z\-]+)">[\n\s]+\{\{> sidebar\}\}[\n\s]+<div class="column-span">

Screenshots

p5-rtl-desktop

more screenshots

Mobile

p5-rtl-mobile

Screen Shot 2020-04-14 at 12 23 36 AM Screen Shot 2020-04-14 at 12 23 45 AM

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.

@@ -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;
Copy link
Member Author

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 😄

@limzykenneth
Copy link
Member

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.

@sepans
Copy link
Member Author

sepans commented Apr 16, 2020

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.

@limzykenneth
Copy link
Member

@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.

Copy link
Member

@limzykenneth limzykenneth left a 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'];
Copy link
Member

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?

Copy link
Member Author

@sepans sepans Apr 16, 2020

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!

Copy link
Member

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 {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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.

@sepans
Copy link
Member Author

sepans commented Apr 16, 2020

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.

@limzykenneth
Copy link
Member

@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.

@lmccart lmccart changed the base branch from master to main June 14, 2020 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants