Skip to content

Commit

Permalink
Merge pull request #45892 from shubham1206agra/pluralizing-translation
Browse files Browse the repository at this point in the history
Added pluralization system for lang translations
  • Loading branch information
iwiznia authored Sep 27, 2024
2 parents 53a11d7 + e514a72 commit 77e2fd9
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 107 deletions.
4 changes: 2 additions & 2 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,12 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
/>

<ConfirmModal
title={translate('iou.deleteExpense')}
title={translate('iou.deleteExpense', {count: 1})}
isVisible={isDeleteRequestModalVisible}
onConfirm={deleteTransaction}
onCancel={() => setIsDeleteRequestModalVisible(false)}
onModalHide={() => ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current)}
prompt={translate('iou.deleteConfirmation')}
prompt={translate('iou.deleteConfirmation', {count: 1})}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
danger
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProcessMoneyReportHoldMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function ProcessMoneyReportHoldMenu({
if (nonHeldAmount) {
return translate(isApprove ? 'iou.confirmApprovalAmount' : 'iou.confirmPayAmount');
}
return translate(isApprove ? 'iou.confirmApprovalAllHoldAmount' : 'iou.confirmPayAllHoldAmount', {transactionCount});
return translate(isApprove ? 'iou.confirmApprovalAllHoldAmount' : 'iou.confirmPayAllHoldAmount', {count: transactionCount});
}, [nonHeldAmount, transactionCount, translate, isApprove]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ function ReportPreview({
}
return {
supportText: translate('iou.expenseCount', {
count: numberOfRequests,
scanningReceipts: numberOfScanningReceipts,
pendingReceipts: numberOfPendingRequests,
count: numberOfRequests,
}),
};
}, [formattedMerchant, formattedDescription, moneyRequestComment, translate, numberOfRequests, numberOfScanningReceipts, numberOfPendingRequests]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa
shouldAlwaysShowDropdownMenu
pressOnEnter
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM}
customText={translate('workspace.common.selected', {selectedNumber: selectedTransactionsKeys.length})}
customText={translate('workspace.common.selected', {count: selectedTransactionsKeys.length})}
options={headerButtonsOptions}
isSplitButton={false}
shouldUseStyleUtilityForAnchorPosition
Expand Down
84 changes: 56 additions & 28 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CONST as COMMON_CONST, Str} from 'expensify-common';
import {CONST as COMMON_CONST} from 'expensify-common';
import startCase from 'lodash/startCase';
import CONST from '@src/CONST';
import type {Country} from '@src/CONST';
Expand All @@ -8,7 +8,6 @@ import type {
AddEmployeeParams,
AddressLineParams,
AdminCanceledRequestParams,
AgeParams,
AlreadySignedInParams,
ApprovalWorkflowErrorParams,
ApprovedAmountParams,
Expand Down Expand Up @@ -42,7 +41,6 @@ import type {
CharacterLengthLimitParams,
CharacterLimitParams,
CompanyCardFeedNameParams,
ConfirmHoldExpenseParams,
ConfirmThatParams,
ConnectionNameParams,
ConnectionParams,
Expand All @@ -57,10 +55,7 @@ import type {
DelegatorParams,
DeleteActionParams,
DeleteConfirmationParams,
DeleteExpenseTranslationParams,
DidSplitAmountMessageParams,
DimensionsCountParams,
DistanceRateOperationsParams,
EditActionParams,
ElectronicFundsParams,
EnterMagicCodeParams,
Expand Down Expand Up @@ -133,7 +128,6 @@ import type {
RoomNameReservedErrorParams,
RoomRenamedToParams,
SecondaryLoginParams,
SelectedNumberParams,
SetTheDistanceMerchantParams,
SetTheRequestParams,
SettledAfterAddedBankAccountParams,
Expand Down Expand Up @@ -846,7 +840,10 @@ const translations = {
receiptScanning: 'Receipt scanning...',
receiptScanInProgress: 'Receipt scan in progress',
receiptScanInProgressDescription: 'Receipt scan in progress. Check back later or enter the details now.',
receiptIssuesFound: ({count}: DistanceRateOperationsParams) => `${count === 1 ? 'Issue' : 'Issues'} found`,
receiptIssuesFound: () => ({
one: 'Issue found',
other: 'Issues found',
}),
fieldPending: 'Pending...',
defaultRate: 'Default rate',
receiptMissingDetails: 'Receipt missing details',
Expand All @@ -863,19 +860,27 @@ const translations = {
yourCompanyWebsiteNote: "If you don't have a website, you can provide your company's LinkedIn or social media profile instead.",
invalidDomainError: 'You have entered an invalid domain. To continue, please enter a valid domain.',
publicDomainError: 'You have entered a public domain. To continue, please enter a private domain.',
expenseCount: ({count, scanningReceipts = 0, pendingReceipts = 0}: RequestCountParams) => {
const expenseText = `${count} ${Str.pluralize('expense', 'expenses', count)}`;
const statusText = [];
expenseCount: ({scanningReceipts = 0, pendingReceipts = 0}: RequestCountParams) => {
const statusText: string[] = [];
if (scanningReceipts > 0) {
statusText.push(`${scanningReceipts} scanning`);
}
if (pendingReceipts > 0) {
statusText.push(`${pendingReceipts} pending`);
}
return statusText.length > 0 ? `${expenseText} (${statusText.join(', ')})` : expenseText;
},
deleteExpense: ({count}: DeleteExpenseTranslationParams = {count: 1}) => `Delete ${Str.pluralize('expense', 'expenses', count)}`,
deleteConfirmation: ({count}: DeleteExpenseTranslationParams = {count: 1}) => `Are you sure that you want to delete ${Str.pluralize('this expense', 'these expenses', count)}?`,
return {
one: statusText.length > 0 ? `1 expense (${statusText.join(', ')})` : `1 expense`,
other: (count: number) => (statusText.length > 0 ? `${count} expenses (${statusText.join(', ')})` : `${count} expenses`),
};
},
deleteExpense: () => ({
one: 'Delete expense',
other: 'Delete expenses',
}),
deleteConfirmation: () => ({
one: 'Are you sure that you want to delete this expense?',
other: 'Are you sure that you want to delete these expenses?',
}),
settledExpensify: 'Paid',
settledElsewhere: 'Paid elsewhere',
individual: 'Individual',
Expand Down Expand Up @@ -976,12 +981,16 @@ const translations = {
keepAll: 'Keep all',
confirmApprove: 'Confirm approval amount',
confirmApprovalAmount: 'Approve only compliant expenses, or approve the entire report.',
confirmApprovalAllHoldAmount: ({transactionCount}: ConfirmHoldExpenseParams) =>
`${Str.pluralize('This expense is', 'These expenses are', transactionCount)} on hold. Do you want to approve anyway?`,
confirmApprovalAllHoldAmount: () => ({
one: 'This expense is on hold. Do you want to approve anyway?',
other: 'These expenses are on hold. Do you want to approve anyway?',
}),
confirmPay: 'Confirm payment amount',
confirmPayAmount: "Pay what's not on hold, or pay the entire report.",
confirmPayAllHoldAmount: ({transactionCount}: ConfirmHoldExpenseParams) =>
`${Str.pluralize('This expense is', 'These expenses are', transactionCount)} on hold. Do you want to pay anyway?`,
confirmPayAllHoldAmount: () => ({
one: 'This expense is on hold. Do you want to pay anyway?',
other: 'These expenses are on hold. Do you want to pay anyway?',
}),
payOnly: 'Pay only',
approveOnly: 'Approve only',
holdEducationalTitle: 'This expense is on',
Expand Down Expand Up @@ -2273,7 +2282,10 @@ const translations = {
testTransactions: 'Test transactions',
issueAndManageCards: 'Issue and manage cards',
reconcileCards: 'Reconcile cards',
selected: ({selectedNumber}: SelectedNumberParams) => `${selectedNumber} selected`,
selected: () => ({
one: '1 selected',
other: (count: number) => `${count} selected`,
}),
settlementFrequency: 'Settlement frequency',
deleteConfirmation: 'Are you sure you want to delete this workspace?',
unavailable: 'Unavailable workspace',
Expand Down Expand Up @@ -2874,7 +2886,10 @@ const translations = {
addAUserDefinedDimension: 'Add a user-defined dimension',
detailedInstructionsLink: 'View detailed instructions',
detailedInstructionsRestOfSentence: ' on adding user-defined dimensions.',
userDimensionsAdded: ({dimensionsCount}: DimensionsCountParams) => `${dimensionsCount} ${Str.pluralize('UDD', `UDDs`, dimensionsCount)} added`,
userDimensionsAdded: () => ({
one: '1 UDD added',
other: (count: number) => `${count} UDDs added`,
}),
mappingTitle: ({mappingName}: IntacctMappingTitleParams) => {
switch (mappingName) {
case CONST.SAGE_INTACCT_CONFIG.MAPPINGS.DEPARTMENTS:
Expand Down Expand Up @@ -3668,16 +3683,25 @@ const translations = {
one: 'Delete rate',
other: 'Delete rates',
}),
enableRates: ({count}: DistanceRateOperationsParams) => `Enable ${Str.pluralize('rate', 'rates', count)}`,
disableRates: ({count}: DistanceRateOperationsParams) => `Disable ${Str.pluralize('rate', 'rates', count)}`,
enableRates: () => ({
one: 'Enable rate',
other: 'Enable rates',
}),
disableRates: () => ({
one: 'Disable rate',
other: 'Disable rates',
}),
enableRate: 'Enable rate',
status: 'Status',
unit: 'Unit',
taxFeatureNotEnabledMessage: 'Taxes must be enabled on the workspace to use this feature. Head over to ',
changePromptMessage: ' to make that change.',
defaultCategory: 'Default category',
deleteDistanceRate: 'Delete distance rate',
areYouSureDelete: ({count}: DistanceRateOperationsParams) => `Are you sure you want to delete ${Str.pluralize('this rate', 'these rates', count)}?`,
areYouSureDelete: () => ({
one: 'Are you sure you want to delete this rate?',
other: 'Are you sure you want to delete these rates?',
}),
},
editor: {
descriptionInputLabel: 'Description',
Expand Down Expand Up @@ -3855,7 +3879,10 @@ const translations = {
maxAge: 'Max age',
maxExpenseAge: 'Max expense age',
maxExpenseAgeDescription: 'Flag spend older than a specific number of days.',
maxExpenseAgeDays: ({age}: AgeParams) => `${age} ${Str.pluralize('day', 'days', age)}`,
maxExpenseAgeDays: () => ({
one: '1 day',
other: (count: number) => `${count} days`,
}),
billableDefault: 'Billable default',
billableDefaultDescription: 'Choose whether cash and credit card expenses should be billable by default. Billable expenses are enabled or disabled in',
billable: 'Billable',
Expand Down Expand Up @@ -3994,9 +4021,10 @@ const translations = {
} else if (submittersNames.length > 2) {
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} and ${submittersNames[submittersNames.length - 1]}`;
}
const workflowWord = Str.pluralize('workflow', 'workflows', submittersNames.length);
const chatWord = Str.pluralize('chat', 'chats', submittersNames.length);
return `removed you from ${joinedNames}'s approval ${workflowWord} and workspace ${chatWord}. Previously submitted reports will remain available for approval in your Inbox.`;
return {
one: `removed you from ${joinedNames}'s approval workflow and workspace chat. Previously submitted reports will remain available for approval in your Inbox.`,
other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`,
};
},
},
roomMembersPage: {
Expand Down
Loading

0 comments on commit 77e2fd9

Please sign in to comment.