-
Notifications
You must be signed in to change notification settings - Fork 228
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
RTL: force (%) symbol to follow text direction #978
RTL: force (%) symbol to follow text direction #978
Conversation
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:
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. |
@ARMBouhali Thank you for the contribution, we will review this once your agreement has been sorted out. |
@ARMBouhali Great, your CLA check is green, our team can review now. |
5d53aef
to
7580a1b
Compare
I've updated the commit message to comply with |
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.
it feels like there's a lot of redundant code in here, but nothing pops to mind as a better way to handle RTL percentages. @arbrandes any chance you have thoughts on any other ways to handle this?
@@ -41,7 +41,7 @@ function CurrentGradeTooltip({ intl, tooltipClassName }) { | |||
overlay={( | |||
<Popover id={`${isPassing ? 'passing' : 'non-passing'}-grade-tooltip`} aria-hidden="true" className={tooltipClassName}> | |||
<Popover.Content data-testid="currentGradeTooltipContent" className={isPassing ? 'text-white' : 'text-dark-700'}> | |||
{currentGrade.toFixed(0)}% | |||
{currentGrade.toFixed(0)}{isLocaleRtl ? '\u200f' : ''}% |
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.
is there a specific reason to use the _ ? _ : _
pattern here instead of hte _ && _
pattern? it seems both patterns are used in this PR.
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.
is there a specific reason to use the
_ ? _ : _
pattern here instead of hte_ && _
pattern? it seems both patterns are used in this PR.
indeed there is a reason; it was for a clean rendering for each context.
condition && text
was used to render a JSX element (DOM literal) as a shorthand forcondition ? text : null
.condition ? text : ''
was needed to render a string within a string template, otherwise, whencondition
is false,condition && text
would give a'false'
string instead of an empty string''
it feels like there's a lot of redundant code in here...
Concise ways to deal with this:
- Add RTL function(s) to
frontend-platform/i18n
to do RTL operations. e.gi18n.adjust('%')
- Render a translated percentage expression using
intl.formatMessage
or<FormattedMessage />
and let translators deal with each instance of%
in every language as I did for the Arabic learning MFE strings. Transifex unfortunately does not show special chars so it's not possible to observe the result without exporting a translation file.
@mattcarter - Hi Mat! Could you please allow actions / tests to run on this item? |
here you go |
Codecov ReportBase: 84.13% // Head: 84.16% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #978 +/- ##
==========================================
+ Coverage 84.13% 84.16% +0.03%
==========================================
Files 264 264
Lines 4519 4529 +10
Branches 1158 1165 +7
==========================================
+ Hits 3802 3812 +10
Misses 697 697
Partials 20 20
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. |
81faa69
to
4512639
Compare
I've rebased the branch for Codecov tests to pass. |
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.
The ways to reduce redundancy mentioned in #978 (comment) feel out of scope for this PR (but it'd be great to make an issue for them)
I see no reason to wait for those changes before merging this.
LGTM!
Friendly ping on this :) |
4512639
to
17e8f44
Compare
17e8f44
to
bbd286b
Compare
@mattcarter @mphilbrick211 One last failing test, but it appears out of reach for me.
Can anyone check what's actually wrong? |
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.
These changes look good to me, and tests are passing. Approved.
Before merging, however, it would be good to have an ok from a frontend-app-learning dev. If none emits an opinion in a day or so, I'll press the merge button.
@arbrandes FYI a similar PR for frontend-app-gradebook has been approved and merged a while ago. |
|
@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. |
TL;DR - This commit makes the percentage (%) symbol appear correctly after numbers for RTL languages.
Background
%
is to come after the number, following the writing direction.What changed?
isRtl
andgetLocale
to apply the fix only if the current user language is right-to-left.%
to follow the RTL direction, we use instead the right-to-left marker character which is a non-printing character that does the exact job.Screenshots

Faulty layout in RTL: the
%
sign appears before the value (to the right)Fixed layout in RTL: the

%
sign appears correctly after the value (to the left)