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

Web - Task messages in Spanish are copied to clipboard in English #26621

Closed
1 of 6 tasks
kbecciv opened this issue Sep 3, 2023 · 11 comments
Closed
1 of 6 tasks

Web - Task messages in Spanish are copied to clipboard in English #26621

kbecciv opened this issue Sep 3, 2023 · 11 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@kbecciv
Copy link

kbecciv commented Sep 3, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open staging and from preferences change the language to Spanish
  2. Create a task and assign someone to it
  3. Click the task to open it
  4. Click a bunch of times on the complete task check box
  5. Notice the task system messages being in spanish
  6. Hover over one of the task system messages and copy to clipboard
  7. Paste the copied message to the composer and notice it's pasted in English

Expected Result:

The pasted message should be in Spanish since we are already translating all these messages and making them available for the front end

Actual Result:

The messages are pasted in English which is inconsistent since they are being viewed in Spanish

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.62.0
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
Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-08-29.at.2.14.55.AM.mov

Expensify/Expensify Issue URL:
Issue reported by: @AmjedNazzal
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693265369973669

View all open jobs on GitHub

@ahmedGaber93
Copy link
Contributor

ahmedGaber93 commented Sep 3, 2023

This issue may fix in this #26571

And this is my proposal.

Proposal

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

Task messages in Spanish are copied to clipboard in English

What is the root cause of that problem?

Inconsistent between two text, the displayed text is the translated for actionName + task title, but the copied text is the originalMessage html

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

We need to copy the translated for actionName + task title instead of originalMessage html

function getTaskStatusMessageText(actionName, reportID) {
    let taskStatusText = '';
    switch (actionName) {
        case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED:
            taskStatusText = Localize.translateLocal('task.messages.completed');
            break;
        case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED:
            taskStatusText = Localize.translateLocal('task.messages.canceled');
            break;
        case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED:
            taskStatusText = Localize.translateLocal('task.messages.reopened');
            break;
        default:
            taskStatusText = Localize.translateLocal('task.task');
    }

    return `${taskStatusText} ${allReports[reportID].reportName}`;
}

and use it here

onPress: (closePopover, {reportAction, selection, reportID}) => {
  // const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', '');
  const messageHtml = isTaskAction ? ReportActionsUtils.getTaskStatusMessageText(reportAction.actionName, reportID) : lodashGet(message, 'html', '');

The function can use also in TaskAction.js

What alternative solutions did you explore? (Optional)

we can use reportAction.childReportName for task title and create a function in ReportActionsUtils.js to get translated value for actionName like the above (taskStatusText part).

@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

Triggered auto assignment to @trjExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@kbecciv
Copy link
Author

kbecciv commented Sep 3, 2023

Proposal by: @AmjedNazzal
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693265369973669

Proposal

AmjedNazzal on GH

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

Task messages in Spanish are copied to clipboard in English

What is the root cause of that problem?

The root cause here is that we are copying the task messages from the originalMessage html coming from the backend directly which is a problem since the backend only returns English messages for tasks.

const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', '');

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

To resolve this issue for this bug and related future bugs we can implement the method in TaskAction.js to start translating these task messages depending on the current language instead of getting it from the backend.
We can start by seperating the logic in TaskAction into a custom hook:

export function useGetTaskStatusText(actionName, translateFn) {
    let taskStatusText = '';
    switch (actionName) {
        case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED:
            taskStatusText = translateFn('task.messages.completed');
            break;
        case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED:
            taskStatusText = translateFn('task.messages.canceled');
            break;
        case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED:
            taskStatusText = translateFn('task.messages.reopened');
            break;
        default:
            taskStatusText = translateFn('task.task');
    }
    return taskStatusText;
}

We can call this hook within TaskAction and within BaseReportActionContextMenu and pass it the actionName and translate hook in order to get the translated message.
Inside of TaskAction:

const taskStatusText = useGetTaskStatusText(props.actionName, props.translate);

Inside of BaseReportActionContextMenu:

const taskActionText = useGetTaskStatusText(props.reportAction.actionName, props.translate)
//Existing code
{_.map(_.filter(ContextMenuActions, shouldShowFilter), (contextAction) => {
    const closePopup = !props.isMini;
    const payload = {
        ..
        taskActionText: taskActionText,
    };

Finally we can use it in ContextMenuActions to set the messageHtml:

onPress: (closePopover, {reportAction, selection, taskActionText}) => {
..
    const messageHtml = isTaskAction ? taskActionText : lodashGet(message, 'html', '');

Result

Screen.Recording.2023-08-29.at.4.02.33.PM.mov

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 5, 2023

Proposal

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

Task messages in Spanish are copied to clipboard in English

What is the root cause of that problem?

We use originalMessage to get the text to be copied here -

const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', '');

and it looks like this
Screenshot 2023-09-05 at 5 00 36 PM

Observe it contains semicolon.
but while rendering it we display that separately(prop translation)

<>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.chatItemMessage, styles.colorMuted]}>{`${taskStatusText} ${taskReportName}`}</Text>
</View>
</>
);
}

That's why when we copy the message we are copying content directly while rendering we first translate and then display

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

For this we can create a new method in ReportActionUtils - getTaskActionText(actionName, reportName) it will return translated key for all the CONST.REPORT.ACTIONS.TYPE and the report name. and then use it on above mentioned line while copying the text.
For getting report name(task name) we can use originalMessage
Screenshot 2023-09-05 at 5 33 02 PM

const messageHtml = isTaskAction ? ReportActionsUtils.getTaskActionText(reportAction.actionName, lodashGet(originalMessage, 'title', '')) : lodashGet(message, 'html', '');

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Sep 6, 2023
@trjExpensify
Copy link
Contributor

Reproducible:

image

@thienlnam assigning you for input on this one as it could be backend related.

@thienlnam
Copy link
Contributor

Yeah definitely part of the problem is that the reportAction message is set in the back-end.

We could do a workaround and fix it in the front-end, or just close and wait until we support localization in the back-end. I don't feel super strongly since it's not really something that will happen often (copying the task system message)

@trjExpensify
Copy link
Contributor

Are task system message the only ones translated? That's another inconsistency then really, isn't it? Why would we translate "completed task" but not "paid $xxx".

CC: @JmillsExpensify has this come on your radar in Espanol?

@melvin-bot melvin-bot bot added the Overdue label Sep 11, 2023
@trjExpensify
Copy link
Contributor

Okay, I can see the paid $x.xx system messages on expense reports are translated. If you click the Copy to clipboard button it pastes in English as well:

xiylELkMS6.mp4

So I think the solution to this is more holistic than just on taskReports.

We could do a workaround and fix it in the front-end, or just close and wait until we support localization in the back-end. I don't feel super strongly since it's not really something that will happen often (copying the task system message)

It doesn't feel that premium in the meantime, but I think I agree with preferring to hold off until we support localisation on the backend.

@thienlnam
Copy link
Contributor

Yeah sounds good, let's put this and related issues on hold then until we do back-end localization

@trjExpensify
Copy link
Contributor

I think we just close it. It's not a bug, it's a limitation of how our implementation of translations work at this time. Once we commit to supporting localisation in the backend, that'll be a project in itself and all of these considerations will be accounted for holistically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

5 participants