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 count param to phrase param and return plural form accordingly #48229

Merged
merged 48 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
736b250
update TranslationBase and make few changes
ZhenjaHorbach Aug 28, 2024
9d42d55
fix conflicts
ZhenjaHorbach Aug 28, 2024
e830bb5
update TranslationBase
ZhenjaHorbach Aug 28, 2024
09f51d4
update translations PART-1
ZhenjaHorbach Aug 29, 2024
a237886
update translations PART-2
ZhenjaHorbach Aug 29, 2024
d0bf65b
update translations PART-3
ZhenjaHorbach Aug 29, 2024
41f0334
update translations PART-4
ZhenjaHorbach Aug 29, 2024
078a5ad
Merge branch 'main' into pluralizing_localization-v2
ZhenjaHorbach Aug 31, 2024
b70f5e4
update TranslationBase type
ZhenjaHorbach Aug 31, 2024
f31c7f2
fix conflicts
ZhenjaHorbach Sep 3, 2024
af67cd0
fix conflicts
ZhenjaHorbach Sep 3, 2024
eab923d
fix conflicts
ZhenjaHorbach Sep 5, 2024
5d1a70c
update new translations
ZhenjaHorbach Sep 5, 2024
41a3199
update TranslationBaseValue
ZhenjaHorbach Sep 5, 2024
8ebf751
revert some changes
ZhenjaHorbach Sep 5, 2024
273c8e1
revert some changes
ZhenjaHorbach Sep 5, 2024
d63aa0d
update type arguments
ZhenjaHorbach Sep 5, 2024
4b7eb6d
fix conflicts
ZhenjaHorbach Sep 9, 2024
57d8b7f
fix ts issues
ZhenjaHorbach Sep 9, 2024
83481bf
fix ts issue with no string values
ZhenjaHorbach Sep 11, 2024
554611c
fix conflicts
ZhenjaHorbach Sep 11, 2024
7c24bb4
update types for translations
ZhenjaHorbach Sep 11, 2024
d3028b6
refactor TranslationBase
ZhenjaHorbach Sep 11, 2024
100feae
refactor some code
ZhenjaHorbach Sep 11, 2024
87fd61d
fix conflicts
ZhenjaHorbach Sep 12, 2024
101fd03
refactor types for translations
ZhenjaHorbach Sep 12, 2024
90af317
update types
ZhenjaHorbach Sep 12, 2024
362c264
fix issue with no object values
ZhenjaHorbach Sep 12, 2024
8f58c9e
fix ts issue in localize
ZhenjaHorbach Sep 12, 2024
04c8f76
fix comments
ZhenjaHorbach Sep 12, 2024
bd485f9
fix conflicts
ZhenjaHorbach Sep 13, 2024
5d73e02
fix conflicts
ZhenjaHorbach Sep 14, 2024
0002662
fix conflicts
ZhenjaHorbach Sep 17, 2024
4e0d494
fix conflicts
ZhenjaHorbach Sep 18, 2024
2b84c98
fix conflicts
ZhenjaHorbach Sep 19, 2024
2175302
update package-lock
ZhenjaHorbach Sep 19, 2024
d7f49e5
update package-lock x2
ZhenjaHorbach Sep 19, 2024
090af99
fix comments
ZhenjaHorbach Sep 19, 2024
e278f17
fix conflicts
ZhenjaHorbach Sep 19, 2024
be492c0
fix conflicts
ZhenjaHorbach Sep 20, 2024
94d170b
fix conflicts
ZhenjaHorbach Sep 24, 2024
ffcd48e
update branch
ZhenjaHorbach Sep 25, 2024
480bdda
fix some comments
ZhenjaHorbach Sep 25, 2024
1ebfb54
update readme
ZhenjaHorbach Sep 25, 2024
27b7056
update readme x2
ZhenjaHorbach Sep 25, 2024
7638a4c
update localize comment
ZhenjaHorbach Sep 25, 2024
12b3b41
fix comments
ZhenjaHorbach Sep 26, 2024
a36a304
refactor plural forms
ZhenjaHorbach Sep 26, 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
2 changes: 1 addition & 1 deletion src/components/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function AccountSwitcher() {
.map(({email, role, error}, index) => {
const personalDetails = PersonalDetailsUtils.getPersonalDetailByEmail(email);
return createBaseMenuItem(personalDetails, error, {
badgeText: translate('delegate.role', role),
badgeText: translate('delegate.role', {role}),
onPress: () => {
if (isOffline) {
Modal.close(() => setShouldShowOfflineModal(true));
Expand Down
4 changes: 2 additions & 2 deletions src/components/AccountingConnectionConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function AccountingConnectionConfirmationModal({integrationToConnect, onCancel,

return (
<ConfirmModal
title={translate('workspace.accounting.connectTitle', integrationToConnect)}
title={translate('workspace.accounting.connectTitle', {connectionName: integrationToConnect})}
isVisible
onConfirm={onConfirm}
onCancel={onCancel}
prompt={translate('workspace.accounting.connectPrompt', integrationToConnect)}
prompt={translate('workspace.accounting.connectPrompt', {connectionName: integrationToConnect})}
confirmText={translate('workspace.accounting.setup')}
cancelText={translate('common.cancel')}
success
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function AddressForm({
if (countrySpecificZipRegex) {
if (!countrySpecificZipRegex.test(values.zipPostCode?.trim().toUpperCase())) {
if (ValidationUtils.isRequiredFulfilled(values.zipPostCode?.trim())) {
errors.zipPostCode = translate('privatePersonalDetails.error.incorrectZipFormat', countryZipFormat);
errors.zipPostCode = translate('privatePersonalDetails.error.incorrectZipFormat', {zipFormat: countryZipFormat});
} else {
errors.zipPostCode = translate('common.error.fieldRequired');
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReceiptAudit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ReceiptAudit({notes, shouldShowAuditResult}: ReceiptAuditProps) {

let auditText = '';
if (notes.length > 0 && shouldShowAuditResult) {
auditText = translate('iou.receiptIssuesFound', notes.length);
auditText = translate('iou.receiptIssuesFound', {count: notes.length});
} else if (!notes.length && shouldShowAuditResult) {
auditText = translate('common.verified');
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/ExportWithDropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function ExportWithDropdownMenu({
const options = [
{
value: CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION,
text: translate('workspace.common.exportIntegrationSelected', connectionName),
text: translate('workspace.common.exportIntegrationSelected', {connectionName}),
...optionTemplate,
},
{
Expand Down Expand Up @@ -126,7 +126,7 @@ function ExportWithDropdownMenu({
title={translate('workspace.exportAgainModal.title')}
onConfirm={confirmExport}
onCancel={() => setModalStatus(null)}
prompt={translate('workspace.exportAgainModal.description', report?.reportName ?? '', connectionName)}
prompt={translate('workspace.exportAgainModal.description', {connectionName, reportName: report?.reportName ?? ''})}
confirmText={translate('workspace.exportAgainModal.confirmText')}
cancelText={translate('workspace.exportAgainModal.cancelText')}
isVisible={!!modalStatus}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/IssueCardMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ function IssueCardMessage({action}: IssueCardMessageProps) {
const getTranslation = () => {
switch (action?.actionName) {
case CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED:
return translate('workspace.expensifyCard.issuedCard', assignee);
return translate('workspace.expensifyCard.issuedCard', {assignee});
case CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL:
return translate('workspace.expensifyCard.issuedCardVirtual', {assignee, link});
case CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS:
return translate(`workspace.expensifyCard.${noMailingAddress ? 'issuedCardNoMailingAddress' : 'addedAddress'}`, assignee);
return translate(`workspace.expensifyCard.${noMailingAddress ? 'issuedCardNoMailingAddress' : 'addedAddress'}`, {assignee});
default:
return '';
}
Expand Down
278 changes: 166 additions & 112 deletions src/languages/en.ts

Large diffs are not rendered by default.

271 changes: 163 additions & 108 deletions src/languages/es.ts

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/languages/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type {TranslationBase, TranslationFlatObject} from './types';
*/
// Necessary to export so that it is accessible to the unit tests
// eslint-disable-next-line rulesdir/no-inline-named-export
export function flattenObject(obj: TranslationBase): TranslationFlatObject {
export function flattenObject<T = typeof en>(obj: TranslationBase<T>): TranslationFlatObject {
const result: Record<string, unknown> = {};

const recursive = (data: TranslationBase, key: string): void => {
const recursive = (data: TranslationBase<T>, key: string): void => {
// If the data is a function or not a object (eg. a string or array),
// it's the final value for the key being built and there is no need
// for more recursion
Expand All @@ -27,7 +27,8 @@ export function flattenObject(obj: TranslationBase): TranslationFlatObject {
// Recursive call to the keys and connect to the respective data
Object.keys(data).forEach((k) => {
isEmpty = false;
recursive(data[k] as TranslationBase, key ? `${key}.${k}` : k);
// @ts-expect-error - The key is a string since forEach is always iterating over the keys like strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blazejkustra
This is still not fixed.

recursive(data[k] as TranslationBase<T>, key ? `${key}.${k}` : k);
});

// Check for when the object is empty but a key exists, so that
Expand Down
Loading
Loading