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

Clean up Localize.js #13778

Merged
merged 14 commits into from
Jan 10, 2023
Merged

Clean up Localize.js #13778

merged 14 commits into from
Jan 10, 2023

Conversation

Luke9389
Copy link
Contributor

@Luke9389 Luke9389 commented Dec 21, 2022

Details

I recently looked into our translation HOC, and noticed that the variable naming made the translate method super hard to read. This PR just cleans that up a little bit.

Fixed Issues

$ GH_LINK
PROPOSAL: GH_LINK_ISSUE(COMMENT)

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

  • Go to Settings > Preferences and change the language to Spanish

  • Visit a bunch of different pages

  • Verify that none of the copy is broken.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Screen Shot 2022-12-21 at 3 07 18 PM
Mobile Web - Chrome

Screenshot_20230109-172834

Mobile Web - Safari Screen Shot 2022-12-21 at 3 08 42 PM
Desktop

Screen Shot 2023-01-04 at 5 35 30 PM

iOS

Screen Shot 2023-01-04 at 5 27 06 PM
Screen Shot 2023-01-04 at 5 27 12 PM

Android

Screen Shot 2023-01-04 at 5 46 35 PM

@Luke9389 Luke9389 self-assigned this Dec 21, 2022
@Luke9389 Luke9389 requested a review from a team as a code owner December 21, 2022 22:37
@melvin-bot melvin-bot bot removed the request for review from a team December 21, 2022 22:38
@melvin-bot
Copy link

melvin-bot bot commented Dec 21, 2022

@AndrewGable 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]

@AndrewGable
Copy link
Contributor

Conflicts

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 3, 2023

Updated!

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

@AndrewGable I noticed you're super busy with expensiconx and margelo this week. I'm happy to reassign this to another reviewer if you'd like.

@AndrewGable
Copy link
Contributor

Looks like some platforms are missing, can you update them?

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

oh! strange. I thought I did those. Maybe I didn't save that edit 😅
comin' right up!

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

Hey, I'm having a bit of an issue testing this on android chrome. Stuck on the splash screen 🤔

I need to run for tonight, but I'll come on back to this one tomorrow. Thanks @AndrewGable!

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

@AndrewGable would you be willing to test this on my behalf while I try to get Android Chrome working? I've been trying different ways to get past the splash screen in the background today and I'm not getting any further with it.

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

Going to try rebooting my vm and computer as a last ditch effort.

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 5, 2023

@Luke9389
Copy link
Contributor Author

Luke9389 commented Jan 6, 2023

So, I'm pretty much blocked on testing in Android Chrome right now. But all the other platforms show translations working, and my Android Chrome env isn't even working on the main branch, so I think this is a pretty safe PR to move forward with at this point.

Ideally you'd be testing the 3 web platforms as a part of the review checklist anyway, so I think it'd be best to move forward with that and merge if you're feeling good. I know you're busy, so take your time, but please don't wait for me (this Android Chrome thing has been a persistent problem for me for the last few days, with no progress yet).

@AndrewGable
Copy link
Contributor

I will help you diagnose in the thread!

@OSBotify
Copy link
Contributor

OSBotify commented Jan 7, 2023

@Luke9389
Copy link
Contributor Author

Hey @AndrewGable, does the build from the comment above work for you on android chrome? If so, can we merge this?
I'm still trying to get my Android Chrome env to work correctly (the link doesn't work for me–same error as in the aforementioned thread).

@AndrewGable
Copy link
Contributor

Hey @Luke9389 - Can we continue the conversation in the thread to track down your issues? If you cannot test on Android mWeb, you won't really be able to merge any PRs, so we should get that sorted as your first priority.

@Luke9389
Copy link
Contributor Author

True, and there isn't really a time constraint with this one.

@Luke9389
Copy link
Contributor Author

OK! Added the screenshot for Android Chrome from my physical device.

Thanks for the help on this one @AndrewGable, I very much appreciate it.

@AndrewGable
Copy link
Contributor

AndrewGable commented Jan 10, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Screenshot 2023-01-10 at 4 02 19 PM
Mobile Web - Chrome Screenshot 2023-01-10 at 4 13 57 PM
Mobile Web - Safari Screenshot 2023-01-10 at 4 02 45 PM
Desktop Screenshot 2023-01-10 at 4 07 46 PM
iOS Screenshot 2023-01-10 at 3 51 16 PM
Android Screenshot 2023-01-10 at 4 08 54 PM

@AndrewGable AndrewGable merged commit a52d724 into main Jan 10, 2023
@AndrewGable AndrewGable deleted the luke-clean-up-localize branch January 10, 2023 23:18
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
App start nativeLaunch 9.281 ms → 19.774 ms (+10.493 ms, +113.1%) 🟡
App start TTI 677.186 ms → 679.255 ms (+2.069 ms, ±0.0%)
App start regularAppStart 0.013 ms → 0.021 ms (+0.007 ms, +55.4%) 🟡
Open Search Page TTI 611.292 ms → 609.710 ms (-1.582 ms, ±0.0%)
App start runJsBundle 190.688 ms → 188.250 ms (-2.438 ms, -1.3%)
Show details
Name Duration
App start nativeLaunch Baseline
Mean: 9.281 ms
Stdev: 1.625 ms (17.5%)
Runs: 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 10 11 11 11 11 13 13 14

Current
Mean: 19.774 ms
Stdev: 1.946 ms (9.8%)
Runs: 17 18 18 18 18 18 18 18 18 18 19 19 19 19 19 20 20 20 20 20 20 20 20 20 21 21 22 22 23 25 25
App start TTI Baseline
Mean: 677.186 ms
Stdev: 32.625 ms (4.8%)
Runs: 612.0927370004356 620.7922660000622 622.8298720000312 628.377329999581 628.8377430001274 646.3416250003502 653.8690269999206 655.1796329999343 656.5895020002499 667.2176930001006 667.7577290004119 671.3772729998454 672.5220090001822 677.3964020004496 679.2630019998178 680.8245270000771 682.1671569999307 683.8060489995405 685.6345690004528 686.1427459996194 693.8208809997886 693.9418660001829 695.9578050002456 700.2653050003573 703.6668459996581 711.8367179995403 712.6948790000752 713.4747759997845 714.9359459998086 718.9820429999381 754.1619669999927

Current
Mean: 679.255 ms
Stdev: 24.440 ms (3.6%)
Runs: 624.1069499999285 640.3902460001409 648.0531430002302 654.2245129998773 655.3627519998699 656.8344010002911 658.3300149999559 659.1601560004056 662.9980110004544 664.5083659999073 667.7499219998717 669.3592480001971 670.5566619997844 674.1709129996598 675.4776140004396 681.2712920000777 682.2264599995688 684.5710580004379 685.9432880003005 687.6640710001811 689.9120570002124 690.209638999775 690.9071500003338 692.8416010001674 692.8623759998009 703.2047920003533 710.3417379995808 712.2522449996322 714.4638179996982 725.9011249998584 731.0384080000222
App start regularAppStart Baseline
Mean: 0.013 ms
Stdev: 0.001 ms (6.0%)
Runs: 0.012370000593364239 0.0125730000436306 0.012613999657332897 0.01269499957561493 0.012776000425219536 0.012776999734342098 0.01285799965262413 0.012898999266326427 0.012939000502228737 0.013143000192940235 0.013143000192940235 0.013264999724924564 0.013306000269949436 0.013345999643206596 0.013387000188231468 0.013387000188231468 0.013427999801933765 0.01358999963849783 0.01375299971550703 0.013794000260531902 0.0138349998742342 0.01403799932450056 0.014403999783098698 0.01444500032812357 0.01448499970138073 0.014526000246405602 0.016235999763011932

Current
Mean: 0.021 ms
Stdev: 0.002 ms (10.8%)
Runs: 0.01859499979764223 0.018596000038087368 0.018718000501394272 0.018799000419676304 0.01887999940663576 0.019001999869942665 0.019286999478936195 0.0194089999422431 0.019612999632954597 0.019694000482559204 0.0197350000962615 0.019816000014543533 0.019816000014543533 0.019896999932825565 0.019979000091552734 0.02034500055015087 0.02058899961411953 0.02075199969112873 0.020874000154435635 0.021037000231444836 0.02128100022673607 0.021403000690042973 0.021647000685334206 0.021932000294327736 0.02254300005733967 0.023315999656915665 0.02364099957048893 0.025147000327706337 0.026569999754428864 0.027629000134766102
Open Search Page TTI Baseline
Mean: 611.292 ms
Stdev: 20.171 ms (3.3%)
Runs: 572.5830079996958 572.8964439993724 578.5430910000578 585.8537600003183 586.7328700004146 587.5265300003812 590.6784270005301 599.3266610000283 600.3033039998263 600.3340259995311 602.1838790001348 602.9132890002802 604.3715009996668 607.040853000246 608.6390789998695 611.4394939998165 613.2088219998404 614.3339439993724 615.4170740004629 616.8322350000963 617.0578209999949 618.7298580007628 619.8772379998118 621.0406090002507 621.4074709992856 627.5635989997536 629.1931159999222 629.6938880002126 639.4894619993865 641.4804279999807 643.5698659997433 644.6651210002601 647.7014979999512

Current
Mean: 609.710 ms
Stdev: 21.511 ms (3.5%)
Runs: 569.9853929998353 582.1233320003375 582.4859210001305 584.547242000699 585.0771080004051 586.5380860008299 594.1121420003474 595.0698650004342 596.9001460000873 598.0242109997198 598.4770100004971 599.134683999233 601.109822999686 602.0156659996137 602.9596760002896 603.8262940002605 605.9136150004342 608.4323730003089 608.8719080006704 609.0859369998798 609.1713870000094 611.5157480007038 620.86661899928 621.3366709994152 625.0457359999418 626.4836019994691 626.7158610001206 630.6907150000334 635.240396999754 635.7831630008295 638.4406329998747 660.5607510004193 663.8766280002892
App start runJsBundle Baseline
Mean: 190.688 ms
Stdev: 26.772 ms (14.0%)
Runs: 154 156 156 159 159 164 164 166 166 168 169 177 186 187 192 193 194 194 194 196 199 201 204 205 209 210 212 213 213 223 256 263

Current
Mean: 188.250 ms
Stdev: 19.218 ms (10.2%)
Runs: 161 162 164 165 166 169 170 171 172 173 176 176 178 183 183 187 189 192 192 194 195 196 202 202 202 203 204 205 210 214 234 234

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @AndrewGable in version: 1.2.53-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.2.53-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants