From b4d2d6a884eab27bbb30e6ce35aafb1bd62b8921 Mon Sep 17 00:00:00 2001
From: Ali Gradina <71004080+a-gradina@users.noreply.github.com>
Date: Tue, 19 Nov 2024 19:52:24 +0100
Subject: [PATCH] Marked files for translation (#3548)
---
.../src/components/reports/DateRange.tsx | 49 +++++++++++--------
.../src/components/reports/ReportOptions.ts | 48 +++++++++---------
.../src/components/reports/disabledList.ts | 20 ++++----
.../src/components/reports/index.tsx | 6 ++-
upcoming-release-notes/3548.md | 6 +++
5 files changed, 75 insertions(+), 54 deletions(-)
create mode 100644 upcoming-release-notes/3548.md
diff --git a/packages/desktop-client/src/components/reports/DateRange.tsx b/packages/desktop-client/src/components/reports/DateRange.tsx
index 29d743064b4..81d6fbeabae 100644
--- a/packages/desktop-client/src/components/reports/DateRange.tsx
+++ b/packages/desktop-client/src/components/reports/DateRange.tsx
@@ -1,4 +1,5 @@
import React, { type ReactElement } from 'react';
+import { Trans } from 'react-i18next';
import * as d from 'date-fns';
@@ -36,39 +37,45 @@ export function DateRange({ start, end, type }: DateRangeProps): ReactElement {
} else {
return (
- There was a problem loading your date range
+ There was a problem loading your date range
);
}
+ const formattedStartDate = d.format(startDate, 'MMM yyyy');
+ const formattedEndDate = d.format(endDate, 'MMM yyyy');
+ let typeOrFormattedEndDate: string;
+
+ if (type && ['budget', 'average'].includes(type)) {
+ typeOrFormattedEndDate = type === 'budget' ? 'budgeted' : type;
+ } else {
+ typeOrFormattedEndDate = formattedEndDate;
+ }
+
let content: string | ReactElement;
if (['budget', 'average'].includes(type || '')) {
content = (
- Compare {d.format(startDate, 'MMM yyyy')} to{' '}
- {type === 'budget' ? 'budgeted' : 'average'}
-
- );
- } else if (startDate.getFullYear() !== endDate.getFullYear()) {
- content = (
-
- {type && 'Compare '}
- {d.format(startDate, 'MMM yyyy')}
- {type ? ' to ' : ' - '}
- {['budget', 'average'].includes(type || '')
- ? type
- : d.format(endDate, 'MMM yyyy')}
+
+ Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
+
);
- } else if (startDate.getMonth() !== endDate.getMonth()) {
+ } else if (
+ startDate.getFullYear() !== endDate.getFullYear() ||
+ startDate.getMonth() !== endDate.getMonth()
+ ) {
content = (
- {type && 'Compare '}
- {d.format(startDate, 'MMM yyyy')}
- {type ? ' to ' : ' - '}
- {['budget', 'average'].includes(type || '')
- ? type
- : d.format(endDate, 'MMM yyyy')}
+ {type ? (
+
+ Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
+
+ ) : (
+
+ {{ formattedStartDate }} - {{ formattedEndDate }}
+
+ )}
);
} else {
diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts
index 1ef7d652e9d..d8f2ed7fce6 100644
--- a/packages/desktop-client/src/components/reports/ReportOptions.ts
+++ b/packages/desktop-client/src/components/reports/ReportOptions.ts
@@ -1,3 +1,5 @@
+import { t } from 'i18next';
+
import * as monthUtils from 'loot-core/src/shared/months';
import {
type CustomReportEntity,
@@ -32,11 +34,11 @@ export const defaultReport: CustomReportEntity = {
};
const balanceTypeOptions = [
- { description: 'Payment', format: 'totalDebts' as const },
- { description: 'Deposit', format: 'totalAssets' as const },
- { description: 'Net', format: 'totalTotals' as const },
- { description: 'Net Payment', format: 'netDebts' as const },
- { description: 'Net Deposit', format: 'netAssets' as const },
+ { description: t('Payment'), format: 'totalDebts' as const },
+ { description: t('Deposit'), format: 'totalAssets' as const },
+ { description: t('Net'), format: 'totalTotals' as const },
+ { description: t('Net Payment'), format: 'netDebts' as const },
+ { description: t('Net Deposit'), format: 'netAssets' as const },
];
const groupByOptions = [
@@ -59,7 +61,7 @@ export type dateRangeProps = {
const dateRangeOptions: dateRangeProps[] = [
{
- description: 'This week',
+ description: t('This week'),
name: 0,
type: 'Week',
Daily: true,
@@ -68,7 +70,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Last week',
+ description: t('Last week'),
name: 1,
type: 'Week',
Daily: true,
@@ -77,7 +79,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'This month',
+ description: t('This month'),
name: 0,
type: 'Month',
Daily: true,
@@ -86,7 +88,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Last month',
+ description: t('Last month'),
name: 1,
type: 'Month',
Daily: true,
@@ -95,7 +97,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Last 3 months',
+ description: t('Last 3 months'),
name: 3,
type: 'Month',
Daily: true,
@@ -104,7 +106,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Last 6 months',
+ description: t('Last 6 months'),
name: 6,
type: 'Month',
Daily: false,
@@ -113,7 +115,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Last 12 months',
+ description: t('Last 12 months'),
name: 12,
type: 'Month',
Daily: false,
@@ -122,7 +124,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
- description: 'Year to date',
+ description: t('Year to date'),
name: 'yearToDate',
type: 'Month',
Daily: false,
@@ -131,7 +133,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: true,
},
{
- description: 'Last year',
+ description: t('Last year'),
name: 'lastYear',
type: 'Month',
Daily: false,
@@ -140,7 +142,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: true,
},
{
- description: 'All time',
+ description: t('All time'),
name: 'allTime',
type: 'Month',
Daily: false,
@@ -163,27 +165,27 @@ type intervalOptionsProps = {
const intervalOptions: intervalOptionsProps[] = [
{
- description: 'Daily',
+ description: t('Daily'),
name: 'Day',
format: 'yy-MM-dd',
range: 'dayRangeInclusive',
},
{
- description: 'Weekly',
+ description: t('Weekly'),
name: 'Week',
format: 'yy-MM-dd',
range: 'weekRangeInclusive',
},
//{ value: 3, description: 'Fortnightly', name: 3},
{
- description: 'Monthly',
+ description: t('Monthly'),
name: 'Month',
// eslint-disable-next-line rulesdir/typography
format: "MMM ''yy",
range: 'rangeInclusive',
},
{
- description: 'Yearly',
+ description: t('Yearly'),
name: 'Year',
format: 'yyyy',
range: 'yearRangeInclusive',
@@ -243,19 +245,19 @@ export type UncategorizedEntity = Pick<
const uncategorizedCategory: UncategorizedEntity = {
id: '',
- name: 'Uncategorized',
+ name: t('Uncategorized'),
uncategorized_id: 'other',
hidden: false,
};
const transferCategory: UncategorizedEntity = {
id: '',
- name: 'Transfers',
+ name: t('Transfers'),
uncategorized_id: 'transfer',
hidden: false,
};
const offBudgetCategory: UncategorizedEntity = {
id: '',
- name: 'Off Budget',
+ name: t('Off Budget'),
uncategorized_id: 'off_budget',
hidden: false,
};
@@ -269,7 +271,7 @@ type UncategorizedGroupEntity = Pick<
};
const uncategorizedGroup: UncategorizedGroupEntity = {
- name: 'Uncategorized & Off Budget',
+ name: t('Uncategorized & Off Budget'),
id: 'uncategorized',
hidden: false,
uncategorized_id: 'all',
diff --git a/packages/desktop-client/src/components/reports/disabledList.ts b/packages/desktop-client/src/components/reports/disabledList.ts
index 4042ad77ac1..99ebe0f79cf 100644
--- a/packages/desktop-client/src/components/reports/disabledList.ts
+++ b/packages/desktop-client/src/components/reports/disabledList.ts
@@ -1,41 +1,43 @@
+import { t } from 'i18next';
+
const intervalOptions = [
{
- description: 'Daily',
+ description: t('Daily'),
defaultRange: 'This month',
},
{
- description: 'Weekly',
+ description: t('Weekly'),
defaultRange: 'Last 3 months',
},
{
- description: 'Monthly',
+ description: t('Monthly'),
defaultRange: 'Last 6 months',
},
{
- description: 'Yearly',
+ description: t('Yearly'),
defaultRange: 'Year to date',
},
];
const currentIntervalOptions = [
{
- description: 'This week',
+ description: t('This week'),
disableInclude: true,
},
{
- description: 'This month',
+ description: t('This month'),
disableInclude: true,
},
{
- description: 'Year to date',
+ description: t('Year to date'),
disableInclude: true,
},
{
- description: 'Last year',
+ description: t('Last year'),
disableInclude: true,
},
{
- description: 'All time',
+ description: t('All time'),
disableInclude: true,
},
];
diff --git a/packages/desktop-client/src/components/reports/index.tsx b/packages/desktop-client/src/components/reports/index.tsx
index ad7812ae2c6..3a8165db1e3 100644
--- a/packages/desktop-client/src/components/reports/index.tsx
+++ b/packages/desktop-client/src/components/reports/index.tsx
@@ -1,12 +1,16 @@
+import { useTranslation } from 'react-i18next';
+
import { View } from '../common/View';
import { LoadComponent } from '../util/LoadComponent';
export function Reports() {
+ const { t } = useTranslation();
+
return (
import(/* webpackChunkName: 'reports' */ './ReportRouter')
}
diff --git a/upcoming-release-notes/3548.md b/upcoming-release-notes/3548.md
new file mode 100644
index 00000000000..55f83991cbd
--- /dev/null
+++ b/upcoming-release-notes/3548.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [a-gradina]
+---
+
+Support translations in various files.