Skip to content

Commit

Permalink
Merge pull request Expensify#26370 from hungvu193/feature/26369
Browse files Browse the repository at this point in the history
Translate the MODIFIEDEXPENSE messages
  • Loading branch information
mountiny authored Sep 11, 2023
2 parents 575891b + 3db0427 commit 7f5c14a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ import type {
OOOEventSummaryPartialDayParams,
ParentNavigationSummaryParams,
ManagerApprovedParams,
SetTheRequestParams,
UpdatedTheRequestParams,
RemovedTheRequestParams,
} from './types';
import * as ReportActionsUtils from '../libs/ReportActionsUtils';

Expand Down Expand Up @@ -523,6 +526,11 @@ export default {
paidUsingExpensifyWithAmount: ({amount}: PaidUsingExpensifyWithAmountParams) => `paid ${amount} using Expensify`,
noReimbursableExpenses: 'This report has an invalid amount',
pendingConversionMessage: "Total will update when you're back online",
changedTheRequest: 'changed the request',
setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `set the ${valueName} to ${newValueToDisplay}`,
removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `removed the ${valueName} (previously ${oldValueToDisplay})`,
updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) =>
`changed the ${valueName} to ${newValueToDisplay} (previously ${oldValueToDisplay})`,
threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`,
threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`,
error: {
Expand Down
9 changes: 9 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ import type {
OOOEventSummaryPartialDayParams,
ParentNavigationSummaryParams,
ManagerApprovedParams,
SetTheRequestParams,
UpdatedTheRequestParams,
RemovedTheRequestParams,
} from './types';

/* eslint-disable max-len */
Expand Down Expand Up @@ -524,6 +527,12 @@ export default {
paidUsingExpensifyWithAmount: ({amount}: PaidUsingExpensifyWithAmountParams) => `pagó ${amount} con Expensify`,
noReimbursableExpenses: 'El importe de este informe no es válido',
pendingConversionMessage: 'El total se actualizará cuando estés online',
changedTheRequest: 'cambió la solicitud',
setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `estableció ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay}`,
removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) =>
`eliminó ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`,
updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) =>
`cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`,
threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`,
error: {
Expand Down
9 changes: 9 additions & 0 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ type OOOEventSummaryPartialDayParams = {summary: string; timePeriod: string; dat

type ParentNavigationSummaryParams = {rootReportName: string; workspaceName: string};

type SetTheRequestParams = {valueName: string; newValueToDisplay: string};

type RemovedTheRequestParams = {valueName: string; oldValueToDisplay: string};

type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; oldValueToDisplay: string};

export type {
AddressLineParams,
CharacterLimitParams,
Expand Down Expand Up @@ -252,4 +258,7 @@ export type {
OOOEventSummaryFullDayParams,
OOOEventSummaryPartialDayParams,
ParentNavigationSummaryParams,
SetTheRequestParams,
UpdatedTheRequestParams,
RemovedTheRequestParams,
};
17 changes: 9 additions & 8 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1478,14 +1478,15 @@ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceip
function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, valueInQuotes) {
const newValueToDisplay = valueInQuotes ? `"${newValue}"` : newValue;
const oldValueToDisplay = valueInQuotes ? `"${oldValue}"` : oldValue;
const displayValueName = valueName.toLowerCase();

if (!oldValue) {
return `set the ${valueName} to ${newValueToDisplay}`;
return Localize.translateLocal('iou.setTheRequest', {valueName: displayValueName, newValueToDisplay});
}
if (!newValue) {
return `removed the ${valueName} (previously ${oldValueToDisplay})`;
return Localize.translateLocal('iou.removedTheRequest', {valueName: displayValueName, oldValueToDisplay});
}
return `changed the ${valueName} to ${newValueToDisplay} (previously ${oldValueToDisplay})`;
return Localize.translateLocal('iou.updatedTheRequest', {valueName: displayValueName, newValueToDisplay, oldValueToDisplay});
}

/**
Expand All @@ -1497,7 +1498,7 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName,
function getModifiedExpenseMessage(reportAction) {
const reportActionOriginalMessage = lodashGet(reportAction, 'originalMessage', {});
if (_.isEmpty(reportActionOriginalMessage)) {
return `changed the request`;
return Localize.translateLocal('iou.changedTheRequest');
}

const hasModifiedAmount =
Expand All @@ -1512,25 +1513,25 @@ function getModifiedExpenseMessage(reportAction) {
const currency = reportActionOriginalMessage.currency;
const amount = CurrencyUtils.convertToDisplayString(reportActionOriginalMessage.amount, currency);

return getProperSchemaForModifiedExpenseMessage(amount, oldAmount, 'amount', false);
return getProperSchemaForModifiedExpenseMessage(amount, oldAmount, Localize.translateLocal('iou.amount'), false);
}

const hasModifiedComment = _.has(reportActionOriginalMessage, 'oldComment') && _.has(reportActionOriginalMessage, 'newComment');
if (hasModifiedComment) {
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.newComment, reportActionOriginalMessage.oldComment, 'description', true);
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.newComment, reportActionOriginalMessage.oldComment, Localize.translateLocal('common.description'), true);
}

const hasModifiedCreated = _.has(reportActionOriginalMessage, 'oldCreated') && _.has(reportActionOriginalMessage, 'created');
if (hasModifiedCreated) {
// Take only the YYYY-MM-DD value as the original date includes timestamp
let formattedOldCreated = parseISO(reportActionOriginalMessage.oldCreated);
formattedOldCreated = format(formattedOldCreated, CONST.DATE.FNS_FORMAT_STRING);
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.created, formattedOldCreated, 'date', false);
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.created, formattedOldCreated, Localize.translateLocal('common.date'), false);
}

const hasModifiedMerchant = _.has(reportActionOriginalMessage, 'oldMerchant') && _.has(reportActionOriginalMessage, 'merchant');
if (hasModifiedMerchant) {
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.merchant, reportActionOriginalMessage.oldMerchant, 'merchant', true);
return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.merchant, reportActionOriginalMessage.oldMerchant, Localize.translateLocal('common.merchant'), true);
}
}

Expand Down

0 comments on commit 7f5c14a

Please sign in to comment.