-
Notifications
You must be signed in to change notification settings - Fork 3k
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-02-22] [$500] Language - Error message on New contact method page remains on Spanish #34684
Comments
Job added to Upwork: https://www.upwork.com/jobs/~01926d8327e3320b3a |
Triggered auto assignment to @michaelhaxhiu ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane ( |
ProposalPlease re-state the problem that we are trying to solve in this issueError message on New contact method page remains on Spanish when other device change the language to English. What is the root cause of that problem?This happens because when we called the validate memozied function by clicking the Add button while the translation was in Spanish but then we changed the language back to English from the other device, the validate function didn't get called again in order to update the translation to English. What changes do you think we should make in order to solve the problem?Add logic that calls the validate function when For this we would do the following: App/src/components/Form/FormProvider.js Line 387 in 4b7b8f2
This will update the error translation to English at the same time with the other translations. What alternative solutions did you explore? (Optional)For a more holistic approach we can have a VideosMacOS: Chrome | iOS: NativeScreen.Recording.2024-01-18.at.02.21.19.mov |
ProposalPlease re-state the problem that we are trying to solve in this issue.Error messages in forms doesn't get updated on locale change What is the root cause of that problem?Error messages for form inputs gets set by the
App/src/pages/settings/Profile/Contacts/NewContactMethodPage.js Lines 66 to 86 in 4b7b8f2
The validate method gets invoked on submit, onBlur and onValue change events. A locale change event doesn't retrigger the validate function. So the error messages continue to be in the same locale as it was previously set. What changes do you think we should make in order to solve the problem?As this happens to all Forms in the app, fix should be global. Listen to locale changes in FormProvider and invoke validate method if there are any existing errors in the form. const FormProvider = forwardRef(
({validate, formID, shouldValidateOnBlur, shouldValidateOnChange, children, formState, network, enabledWhenOffline, draftValues, onSubmit, ...rest}, forwardedRef) => {
const inputRefs = useRef({});
const {preferredLocale} = useLocalize();
useEffect(() => {
if (_.keys(errors).length === 0) {
return;
}
const trimmedStringValues = ValidationUtils.prepareValues(inputValues);
onValidate(trimmedStringValues);
// Run this effect only on locale change
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [preferredLocale]); Result Before Screen.Recording.2024-01-18.at.5_out.mp4After Screen.Recording.2024-01-18.at.6_out.mp4What alternative solutions did you explore? (Optional)None (edited) |
ProposalPlease re-state the problem that we are trying to solve in this issue.Language - Error message on New contact method page remains on Spanish What is the root cause of that problem?We are not running the validate method when we detect the language was changed in NewContactMethodPage. What changes do you think we should make in order to solve the problem?The simplest solution is adding a reference to submit button to call validate function when preferredLocale change, we can get this with useEffect:
We get this sending a submit button ref in FormProvider like (submitButtonRef={submitButtonRef}):
Of course we should add the ref to reach the submit button, like ( ref={submitButtonRef}):
Result: Translate.on.submit.mp4 |
ProposalPlease re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
function addErrorMessage<TKey extends TranslationPaths>(errors: ErrorsList, inputID?: string, message?: TKey) {
...
if (!error) {
+ errorList[inputID] = [translatedMessage, {isTranslated: true, key: message}];
}
...
}
+ function translateIfPhraseKey(message: MaybePhraseKey, forceTranslate: boolean = false): string {
...
if (variables?.isTranslated) {
+ if (forceTranslate && variables.key) {
+ return translateLocal(variables.key as TranslationPaths, variables as never);
+ }
return phrase;
}
...
}
+ const translatedMessage = Localize.translateIfPhraseKey(message, true); What alternative solutions did you explore? (Optional)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Language - Error message on New contact method page remains on Spanish What is the root cause of that problem?Error messages are generated by the validate function , which is not called after changing the language. What changes do you think we should make in order to solve the problem?We can jus return translation keys instead translated messages in addErrorMessage function. and use this keys to display text. To do that we can make below changes
What alternative solutions did you explore? (Optional) |
@rushatgabhane let's get review on these proposal when you have a chance |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
I like @ikevin127's alternative proposal #34684 (comment) |
Triggered auto assignment to @mountiny, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@rushatgabhane What do you think about my proposal here? |
|
@rushatgabhane interesting points from @DylanDylann if this is not happening across different forms. What do you think? |
We are already passing the translation key, right?
|
@rushatgabhane Yes. We are passing the translation key, but the addErrorMessage will return something like:
|
@rushatgabhane Do you have any feedback about my comment here? |
Can I get assigned so I can start working on a PR as per reviewer decision here #34684 (comment) ? It's been 6 days since the reviewer's decision without any change or re-assignment. |
Looks like the automation might've failed to set the 7-day hold for payment since the PR #35509 (comment) was deployed to production ~4 hours ago 🧐 |
requested $500 on newdot here - https://staging.new.expensify.com/r/6728438891608723 |
@laurenreidexpensify could you please attach payment summary, thanks 🙇 |
Payment Summary: Contributor: $500 @ikevin127 to be paid in Upwork on 22 Feb |
@rushatgabhane can you do checklist thanks! |
Payment Summary: Contributor: $500 @ikevin127 paid in Upwork on 22 Feb Outstanding action: checklist / regression test confirmation from @rushatgabhane |
$500 approved for @rushatgabhane based on summary above. |
|
@rushatgabhane bump to wrap up thanks |
@rushatgabhane, @mountiny, @ikevin127, @laurenreidexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@rushatgabhane can we get this one wrapped in next day pls :) Thanks! |
@laurenreidexpensify sorry for the delay. updated the checklist : ) |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 1.4.26-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:
Action Performed:
Expected Result:
Contact method with error message should appear on English language
Actual Result:
Error message on New contact method page remains on Spanish when other device change the language to English
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6345811_1705525925897.Recording__1838.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: