Repository navigation
Localize the GPS distance counter number and unit with Intl.NumberFormat - #103796
Conversation
… controls number, spacing and unit Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
🤖 Web test steps verification results: I didn't run a web test, for two reasons:
To get proof of the change, add test steps for iOS or Android to the PR. Then ask me to run them on Android, for example after a GPS trip in |
|
The failing checks are unrelated to this PR, so I didn't push a fix. The PR only changes
Once |
|
The checks haven't changed since my last comment. Neither failure comes from this PR, so I didn't push a fix.
Once |
|
@MelvinBot Please update TestsPrecondition:
Offline testsN/A. Not required, it just a UI change. QA StepsSame as Tests step PR Author ChecklistMark all author checklist checked |
|
@MelvinBot Mark this PR ready for review |
|
I updated the PR description:
I left the two "Verify that no errors appear in the JS console" boxes under Tests and QA Steps unchecked, because they aren't part of the author checklist. The Screenshots/Videos sections are still empty. |
|
I marked this PR ready for review. |
|
@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3380e4938
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| part.type === 'unit' ? ( | ||
| <Text | ||
| key="unit" | ||
| style={styles.colorMuted} |
There was a problem hiding this comment.
Preserve the unit's large text size
The nested Text does not inherit the outer counter's 22px size because the shared Text component applies its default fontSizeNormal whenever no size is supplied. Consequently, every localized unit is rendered at the normal 15px size next to the large distance number, whereas the previous raw unit string inherited styles.textXLarge; apply the counter's large text style to this nested unit as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a689661. The unit now uses [styles.iouAmountTextInput, styles.textXLarge, styles.colorMuted], the same styles the unit had on main.
The nested Text was also resetting the font to the regular face, not only the size. Text.tsx:50 defaults fontSize to the normal size, and Text.tsx:66 defaults the font family. Adding iouAmountTextInput brings back the headline font, and textXLarge brings back the large size. The unit stays muted.
ESLint and the React Compiler check pass on DistanceCounter.tsx:43. typecheck still fails only on the SplitTest.ts errors from main. I didn't check the size on a device.
…tanceCounter Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
|
@chuckdries Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
I merged
Once |
Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
|
I didn't push a fix. The only real failure is still
|
|
The current failing checks are unrelated to this PR, so I didn't push a fix. The PR only changes
Once |
|
I didn't push a fix. The failing checks are the same ones I reported in my last comment, and none of them come from this PR's three files.
Once |
Reviewer Checklist
Screenshots/VideosAndroid: mWeb ChromeiOS: mWeb SafariMacOS: Chrome / Safari |
|
The failed unit test and the typescript error are not related to this PR. |
|
I didn't push a fix. The two real failures come from
Once |
|
The two failing checks are unrelated to this PR, so I didn't push a fix. Both come from code that came in when
After |
|
I didn't push a fix, because nothing has changed since my last reply. Both failures still come from
When |
|
CI should be fixed in main if you wanna merge again |
|
@MelvinBot please merge main |
…tanceCounter Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
|
@chuckdries All checks have passed! |
|
🚧 chuckdries has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.5.10-0 🚀
|
|
No help site update is needed. This PR only changes how the GPS distance counter formats the number and unit for each language. It doesn't make any article sentence wrong. In English, the counter still shows values like |
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.5.12-0 🚀
|
|
No help site update is needed. This PR only changes how the GPS distance counter formats the number and unit for each language, so no article sentence is now wrong. In English, the counter still shows |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.12-1 🚀
Bundle Size Analysis (Sentry): |










Explanation of Change
The GPS distance counter built its value by gluing a
toFixed(2)number, a hard-coded space, and the rawmi/kmvalue together in JSX. Because of that, no locale could change the decimal separator, the spacing, the unit's position, or the unit's spelling.Following
chuckdries's guidance on the issue, this PR formats the value withIntl.NumberFormatinunitstyle and renders theformatToPartsoutput in the order the locale returns it. Only theunitpart is muted, which matches today's styling (bold number, muted unit).NumberFormatUtils.formatDistanceToPartsmapsmi/kmto themile/kilometerIntl units, uses the short unit display, and pins two decimals so values like12.50keep their trailing zero, matching how distances are stored.DistanceCounterpasses the converted distance (convertDistanceUnit) and the user'spreferredLocaleto the helper. Intl does the rounding.Example output:
engives1,234.50 mi,esgives12,50 km, andzh-hansgives12.50英里.Notes for reviewers:
Intl.NumberFormat, not the formatjs polyfill. Hermes listsstyle: 'unit'as having "rough edges" on Android 11, so it's worth checking the unit still comes back as its own muted part on an Android 11 device.IOURequestStepGPSTripEdit) joins{displayDistance} {unit}the same way. I left it out to keep this PR scoped to the issue. It can use the same helper in a follow-up.AI Tests (run by MelvinBot):
npm test -- tests/unit/NumberFormatUtilsTest.ts(26 passed, including 4 newformatDistanceToPartscases)GPSDraftDetailsUtilsTest,useGPSTripStateChecker,BackgroundLocationPermissionsFlowTest,CurrencyUtilsTest(173 passed)npm run typechecknpm run linton the changed filesnpm run react-compiler-compliance-check checkonDistanceCounter.tsxnpm run fmt(no extra changes)lint-changed,spell-changed, andcheck-changedcouldn't run becausegit merge-basefails in the shallow CI checkout. CI will run them.Fixed Issues
$ #103488
PROPOSAL: #103488 (comment)
Tests
Precondition:
0,00 kmor0,00 mi)0.00公里or0.00英里)0.00 mior0.00 km)Offline tests
N/A. Not required, it just a UI change.
QA Steps
Same as Tests step
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari