Skip to content

Commit

Permalink
Merge pull request #25629 from HezekielT/fix--21959-translate-IOU-con…
Browse files Browse the repository at this point in the history
…tents

fix - Translate IOU contents to the correct langauage
  • Loading branch information
madmax330 authored Aug 29, 2023
2 parents 7e524dd + 968e886 commit 6660555
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ function getLastMessageTextForReport(report) {

if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml, translationKey: report.lastMessageTranslationKey})) {
lastMessageTextFromReport = `[${Localize.translateLocal(report.lastMessageTranslationKey || 'common.attachment')}]`;
} else if (ReportActionUtils.isMoneyRequestAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(report, lastReportAction);
} else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) {
const iouReport = ReportUtils.getReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastReportAction);
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const propTypes = {
source: PropTypes.string,
}),

/** Message(text) of an IOU report action */
iouMessage: PropTypes.string,

/** Does this fragment belong to a reportAction that has not yet loaded? */
loading: PropTypes.bool,

Expand Down Expand Up @@ -78,6 +81,7 @@ const defaultProps = {
type: '',
source: '',
},
iouMessage: '',
loading: false,
isSingleLine: false,
source: '',
Expand Down Expand Up @@ -133,7 +137,7 @@ function ReportActionItemFragment(props) {
selectable={!DeviceCapabilities.canUseTouchScreen() || !props.isSmallScreenWidth}
style={[containsOnlyEmojis ? styles.onlyEmojisText : undefined, styles.ltr, ...props.style]}
>
{convertToLTR(text)}
{convertToLTR(props.iouMessage || text)}
{Boolean(props.fragment.isEdited) && (
<Text
fontSize={variables.fontSizeSmall}
Expand Down
10 changes: 10 additions & 0 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ const defaultProps = {
function ReportActionItemMessage(props) {
const messages = _.compact(props.action.previousMessage || props.action.message);
const isAttachment = ReportUtils.isReportMessageAttachment(_.last(messages));
const isIOUReport = ReportActionsUtils.isMoneyRequestAction(props.action);
let iouMessage;
if (isIOUReport) {
const iouReportID = lodashGet(props.action, 'originalMessage.IOUReportID');
if (iouReportID) {
iouMessage = ReportUtils.getReportPreviewMessage(ReportUtils.getReport(iouReportID), props.action);
}
}

return (
<View style={[styles.chatItemMessage, !props.displayAsGroup && isAttachment ? styles.mt2 : {}, ...props.style]}>
{!props.isHidden ? (
Expand All @@ -43,6 +52,7 @@ function ReportActionItemMessage(props) {
key={`actionFragment-${props.action.reportActionID}-${index}`}
fragment={fragment}
isAttachment={props.action.isAttachment}
iouMessage={iouMessage}
hasCommentThread={ReportActionsUtils.hasCommentThread(props.action)}
attachmentInfo={props.action.attachmentInfo}
pendingAction={props.action.pendingAction}
Expand Down

0 comments on commit 6660555

Please sign in to comment.