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

Added pluralization system for lang translations #45892

Merged
merged 32 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e69dd46
Added pluralization system for lang translations
shubham1206agra Jul 22, 2024
e7df141
Fix lint
shubham1206agra Jul 22, 2024
dbc34e6
Apply suggestions from code review
shubham1206agra Jul 25, 2024
7f91f9b
Apply suggestions from code review
shubham1206agra Jul 25, 2024
9e2861d
Merge branch 'main' into pluralizing-translation
shubham1206agra Jul 29, 2024
c8dd8d1
Apply suggestions from code review
shubham1206agra Jul 29, 2024
3a15ab3
Fixed unused type
shubham1206agra Jul 30, 2024
8af7a6f
Merge branch 'main' into pluralizing-translation
shubham1206agra Jul 30, 2024
fd0b5e7
Fixed lint
shubham1206agra Jul 30, 2024
e29c4bf
Fixed lint
shubham1206agra Jul 30, 2024
c4c5787
Merge main
shubham1206agra Aug 1, 2024
5eed7b5
Apply suggestions
shubham1206agra Aug 1, 2024
426d50e
Apply suggestions
shubham1206agra Aug 1, 2024
104979e
Merge branch 'main' into pluralizing-translation
shubham1206agra Aug 5, 2024
158b4c9
Polyfill plural rules for hermes
shubham1206agra Aug 5, 2024
2c7a937
Adjusting position of code
shubham1206agra Aug 5, 2024
14ae63c
Merge branch 'main' into pluralizing-translation
shubham1206agra Aug 6, 2024
2428dfa
Applying suggestion
shubham1206agra Aug 8, 2024
458e9de
Merge branch 'Expensify:main' into pluralizing-translation
shubham1206agra Aug 8, 2024
8155283
Adjusting code
shubham1206agra Aug 8, 2024
c6e69d4
Merge branch 'main' into pluralizing-translation
shubham1206agra Aug 16, 2024
b389316
Apply suggestions from code review
shubham1206agra Aug 16, 2024
6dfb0cd
Apply suggestions from code review
shubham1206agra Aug 16, 2024
08d02c7
Merge branch 'main' into pluralizing-translation
shubham1206agra Aug 23, 2024
8951084
Apply suggestions from code review
shubham1206agra Aug 23, 2024
29124ea
Post merge fixes
shubham1206agra Aug 23, 2024
ff9113a
Merge branch 'main' into pluralizing-translation
shubham1206agra Sep 3, 2024
4722de5
Post merge fixes
shubham1206agra Sep 3, 2024
b0cac2e
Merge branch 'main' into pluralizing-translation
shubham1206agra Sep 5, 2024
75ad856
Merge main
shubham1206agra Sep 27, 2024
1dde318
Merge conflicts
shubham1206agra Sep 27, 2024
e514a72
Fix backticks usage
shubham1206agra Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`,
shubham1206agra marked this conversation as resolved.
Show resolved Hide resolved
}),
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
Loading