Skip to content

Conversation

@ARMBouhali
Copy link
Contributor

@ARMBouhali ARMBouhali commented Sep 15, 2022

TL;DR - This commit replaces the slash / for RTL languages with a backslash \ when it is used to write fractions for such as 2/5 (grades)

Background

  • In fractions, the direction of the slash determines which number comes on top (numerator) and which is on the bottom (denominator). For example: 3 / 2 means "2 over 3, "2 divided by 3" or "2 out of 3"
  • In RTL text, some characters are mirrored to match the writing direction, such as parentheses ( ) and comparison signs < >
  • However, / is not mirrored in RTL, which introduces visual confusion when used to write fractions. For Example, 2 / 3 in English still shows as 2 / 3 in Arabic, while it should look 3 \ 2

What changed?

  • We use 2 frontend-platform functions isRtl and getLocale to apply the fix only if the current user language is right-to-left.
  • we replace / with \ for RTL languages in places where absolute grades are shown.
  • The change is applied to each grade displayed in the progress tab's detailed grade table.

Screenshots (look at the grades)
The screenshots show the detailed grades table in the Arabic language for the DemoX course.

Before After
Screenshot from 2022-09-15 17-56-52 Screenshot from 2022-09-15 17-57-10

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 15, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 15, 2022

Thanks for the pull request, @ARMBouhali! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@natabene
Copy link

@ARMBouhali Thank you, we will review once the agreement is sorted out.

@natabene natabene changed the title RTL: use backslash to write fractions (grades) RTL: use backslash to write fractions (grades) Sep 27, 2022
@natabene natabene changed the title RTL: use backslash to write fractions (grades) RTL: use backslash to write fractions (grades) Sep 27, 2022
@natabene
Copy link

@ARMBouhali Great, your CLA check is green, our team can review now.

@ARMBouhali ARMBouhali force-pushed the rtl-use-backslash-to-write-fractions branch from df9e164 to efbfd54 Compare September 30, 2022 23:35
@ARMBouhali
Copy link
Contributor Author

I updated the commit message to comply with commitlint rules

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Base: 84.13% // Head: 84.18% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (d0cb0c6) compared to base (759d154).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #979      +/-   ##
==========================================
+ Coverage   84.13%   84.18%   +0.05%     
==========================================
  Files         264      264              
  Lines        4519     4521       +2     
  Branches     1158     1159       +1     
==========================================
+ Hits         3802     3806       +4     
+ Misses        697      695       -2     
  Partials       20       20              
Impacted Files Coverage Δ
...tab/grades/detailed-grades/DetailedGradesTable.jsx 100.00% <100.00%> (ø)
...-tab/grades/detailed-grades/ProblemScoreDrawer.jsx 100.00% <100.00%> (ø)
...urseware/course/sidebar/SidebarContextProvider.jsx 100.00% <0.00%> (+9.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of me wishes we had a localizedSlash or something to use instead of needing to copy/paste {isLocaleRtl ? '\\' : '/'} into multiple places, but that feels like premature optimization.

LGTM!

@mphilbrick211
Copy link

@mattcarter - Hi Mat! Could you please allow actions / tests to run on this item?

@ARMBouhali ARMBouhali force-pushed the rtl-use-backslash-to-write-fractions branch 3 times, most recently from b0ad3e9 to fc7d0ec Compare October 13, 2022 08:17
@ARMBouhali
Copy link
Contributor Author

I've rebased the branch for Codecov test to pass.

part of me wishes we had a localizedSlash or something to use instead of needing to copy/paste {isLocaleRtl ? '\\' : '/'} into multiple places, but that feels like premature optimization.

Concise ways to deal with this:

  • Add RTL function(s) to frontend-platform/i18n to do RTL operations. e.g i18n.adjust('/')
  • Render a translated percentage expression using intl.formatMessage or <FormattedMessage /> and let translators deal with each instance of / in every language.

@ARMBouhali ARMBouhali force-pushed the rtl-use-backslash-to-write-fractions branch from fc7d0ec to 8a6742d Compare October 24, 2022 11:40
@ARMBouhali ARMBouhali force-pushed the rtl-use-backslash-to-write-fractions branch from 8a6742d to d0cb0c6 Compare October 24, 2022 11:50
@itsjeyd
Copy link

itsjeyd commented Oct 27, 2022

@ARMBouhali

I've rebased the branch for Codecov test to pass.

Thanks! Looks like this should be ready for merge, then :)

@brian-smith-tcril Since you had already reviewed and okayed these changes a couple weeks ago, would you mind re-approving them?

It looks like that's the only thing left to do before this PR can be merged.

CC @mphilbrick211 @mattcarter

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still looking good!

:shipit:

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@arbrandes arbrandes merged commit bfad5cf into openedx:master Nov 7, 2022
@openedx-webhooks
Copy link

@ARMBouhali 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@ARMBouhali ARMBouhali deleted the rtl-use-backslash-to-write-fractions branch November 7, 2022 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants