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

[HOLD for payment 2024-06-28] [$250] Get rid of MISSING TRANSLATION errors once and for all #42539

Closed
iwiznia opened this issue May 23, 2024 · 42 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@iwiznia
Copy link
Contributor

iwiznia commented May 23, 2024

Context https://expensify.slack.com/archives/C01GTK53T8Q/p1702316632335369

Problem

We've had lots (also search in:#expensify-bugs "missing translation" in slack) of MISSING TRANSLATIONbugs.

These bugs should really not exist ever, they solely exist because we've added a method translateIfPhraseKey that really should never exist, because at every point in our code, we should know if what we have is a translation key or a text to show to the user as is.

Solution

Remove the method.
Change all its usages to:

  • Show the text directly, if the text we have is a text ready to show to the user
  • Call the regular translate method if we have a translation key

cc @StevenKKC @fedirjh

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013d70ff8202e9ba0e
  • Upwork Job ID: 1793684887920951296
  • Last Price Increase: 2024-05-23
  • Automatic offers:
    • fedirjh | Contributor | 102487870
    • nkdengineer | Contributor | 102497969
Issue OwnerCurrent Issue Owner: @nkdengineer
@iwiznia iwiznia added Internal Requires API changes or must be handled by Expensify staff Bug Something is broken. Auto assigns a BugZero manager. labels May 23, 2024
Copy link

melvin-bot bot commented May 23, 2024

Triggered auto assignment to @kadiealexander (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added the Daily KSv2 label May 23, 2024
@iwiznia iwiznia added External Added to denote the issue can be worked on by a contributor and removed Daily KSv2 Internal Requires API changes or must be handled by Expensify staff labels May 23, 2024
@melvin-bot melvin-bot bot changed the title Get rid of MISSING TRANSLATION errors once and for all [$250] Get rid of MISSING TRANSLATION errors once and for all May 23, 2024
Copy link

melvin-bot bot commented May 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~013d70ff8202e9ba0e

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 23, 2024
Copy link

melvin-bot bot commented May 23, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @hungvu193 (External)

@melvin-bot melvin-bot bot added the Daily KSv2 label May 23, 2024
@hunxjunedo
Copy link

Requesting assignment.

Copy link

melvin-bot bot commented May 23, 2024

📣 @hunxjunedo! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@abzokhattab
Copy link
Contributor

abzokhattab commented May 23, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Remove MISSING TRANSLATION ERROR

What is the root cause of that problem?

We've had of MISSING TRANSLATION bugs, they exist because we've added a method translateIfPhraseKey that really should never exist, because at every point in our code, we should know if what we have is a translation key or a text to show to the user as is.

What changes do you think we should make in order to solve the problem?

remove the translateIfPhraseKey function and change all of its usages to:

  1. Call the regular translate method if we have a translation key, for this we need to define a new function inside localize util that would return true if the key exist in the translation file and false otherwise
  2. show the text as its if we dont have the key in the translation file.

@cretadn22
Copy link
Contributor

cretadn22 commented May 23, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Get rid of MISSING TRANSLATION errors once and for all

What is the root cause of that problem?

This is a refactor task

What changes do you think we should make in order to solve the problem?

const uniqueMessages: Array<ReceiptError | string> = [...new Set(sortedMessages)].map((message) => (isReceiptError(message) ? message : Localize.translateIfPhraseKey(message)));

const translatedMessage = Localize.translateIfPhraseKey(message);

const translatedMessage = Localize.translateIfPhraseKey(message);

Currently, we utilize "translateIfPhraseKey" in three places. I propose using the message directly in these three places; there's no need for translation. Then we can identify which cases require translation and update them to use the message directly. This will help maintain consistency across these common components.

What alternative solutions did you explore? (Optional)

@hungvu193
Copy link
Contributor

@iwiznia I saw you tagged @fedirjh, let me know if @fedirjh will handle this one, if yes please unassign me 😄

@iwiznia
Copy link
Contributor Author

iwiznia commented May 24, 2024

I tagged him because IIRC he added that method so he can have context on all this, but I don't think he necessarily has to handle this one.

@iwiznia
Copy link
Contributor Author

iwiznia commented May 24, 2024

Call the regular translate method if we have a translation key, for this we need to define a new function inside localize util that would return true if the key exist in the translation file and false otherwise

I don't think this is good, its improving on what we have, but still does not resolve the main problem which is: whoever is adding a call to translate should know if what they are passing is a text or a key.

Currently, we utilize "translateIfPhraseKey" in three places. I propose using the message directly in these three places; there's no need for translation. Then we can identify which cases require translation and update them to use the message directly. This will help maintain consistency across these common components.

This is not saying much about the solution, since those 3 places are used in like 100 different places.

@nkdengineer
Copy link
Contributor

nkdengineer commented May 24, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

We want to remove the translateIfPhraseKey method

What is the root cause of that problem?

The reason translateIfPhraseKey was added is that for components like FormHelpMessage, DotIndicatorMessage and when adding form errors, we wanted it to support both the use cases of front-end errors and back-end errors.

The idea was to have a data structure MaybePhraseKey for that use case.

However this is not a good pattern, as agreed to in the OP. The components should receive only translated error, whether it's back-end error or not will be controlled by whichever parent components/forms that use those components.

What changes do you think we should make in order to solve the problem?

Already-translated errors will always be a pure string.

  1. We need to update DotIndicatorMessage, FormHelpMessage, addErrorMessage so that they will only receive already-translated errors as props/params

That means for DotIndicatorMessage, messages here will be a map of string and string only

For FormHelpMessage, message here will strictly be a string

For addErrorMessage, message here will strictly be a string

And we'll update the implementations of them accordingly to remove the translation logic. The Localize.MaybePhraseKey should no longer be used in those places.

  1. Most of the places that use DotIndicatorMessage, FormHelpMessage, and 100% of the cases with addErrorMessage, we're dealing with client-side-only errors.

In this case, instead of constructing a MaybePhraseKey and delegate the responsibility of translating it to the lower level components, we should handle the translation in the parent components and just pass the results to those lower level components/methods.

For example, in this case, update to

message={translate("iou.error.splitExpenseMultipleParticipantsErrorMessage")}
  1. There're a few places that use back-end errors/composite client-side errors for those components, in this case, we pass those user-ready errors as is to those components. For example, in this case update to
message={policy?.alertMessage ?? ''}
  1. In case of combination between before-translate error and translated error, like in this, convert it to an array of all translated errors (if error is before-translate, translate it, if error is translated error, do nothing) and use it.

We'll do so across the app, all cases to be updated are mostly of the above 3 categories.

What alternative solutions did you explore? (Optional)

NA

@hungvu193
Copy link
Contributor

I'll review proposals this weekend.

@fedirjh
Copy link
Contributor

fedirjh commented May 24, 2024

cc @hungvu193 @iwiznia I can take over this one.

As for the proposals, I think @nkdengineer proposal looks good

Copy link

melvin-bot bot commented May 27, 2024

@hungvu193, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label May 27, 2024
@hungvu193
Copy link
Contributor

Hmm not sure what should I do in this case.
Cc @iwiznia

@melvin-bot melvin-bot bot removed the Overdue label May 27, 2024
@iwiznia
Copy link
Contributor Author

iwiznia commented May 27, 2024

Ah sorry, going to assign @fedirjh as C+ if you don't mind, since he has more context on this.
@fedirjh make sure to add the comment of the review so it assigns an engineer.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 21, 2024
@melvin-bot melvin-bot bot changed the title [$250] Get rid of MISSING TRANSLATION errors once and for all [HOLD for payment 2024-06-28] [$250] Get rid of MISSING TRANSLATION errors once and for all Jun 21, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jun 21, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.85-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-28. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jun 21, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@fedirjh] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@fedirjh] Determine if we should create a regression test for this bug.
  • [@fedirjh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@kadiealexander] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jun 27, 2024
@kadiealexander
Copy link
Contributor

kadiealexander commented Jul 2, 2024

Payouts due:

Upwork job is here.

@melvin-bot melvin-bot bot removed the Overdue label Jul 2, 2024
@kadiealexander
Copy link
Contributor

@fedirjh please complete the checklist!

@fedirjh
Copy link
Contributor

fedirjh commented Jul 2, 2024

BugZero Checklist:

  • Link to the PR: N/A: This is was a code refactoring
  • Link to comment: N/A
  • Link to discussion: N/A
  • Determine if we should create a regression test for this bug: N/A

@fedirjh
Copy link
Contributor

fedirjh commented Jul 2, 2024

@kadiealexander I will request payment on new Dot.

@JmillsExpensify
Copy link

$250 approved for @fedirjh

@kadiealexander
Copy link
Contributor

@dukenv0307 please let me know when you've accepted the Upwork offer, thanks!

@dukenv0307
Copy link
Contributor

@dukenv0307 please let me know when you've accepted the Upwork offer, thanks!

@kadiealexander Maybe a mistake here, I'm not C or C+ on this issue 😄.

@kadiealexander
Copy link
Contributor

Whoops, you're totally right! Sorry, been a long day. @nkdengineer please let me know when you've accepted the Upwork offer, thanks!

@melvin-bot melvin-bot bot added the Overdue label Jul 8, 2024
@nkdengineer
Copy link
Contributor

@nkdengineer please let me know when you've accepted the Upwork offer, thanks!

@kadiealexander I've done that, thanks

@melvin-bot melvin-bot bot removed the Overdue label Jul 9, 2024
Copy link

melvin-bot bot commented Jul 12, 2024

@francoisl, @fedirjh, @kadiealexander, @nkdengineer Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2024
@francoisl
Copy link
Contributor

@kadiealexander can you confirm all payments have been issued and we can close this please? Thanks!

@kadiealexander
Copy link
Contributor

Yup! All done.

@melvin-bot melvin-bot bot removed the Overdue label Jul 16, 2024
@github-project-automation github-project-automation bot moved this from Polish to Done in [#whatsnext] #expense Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests