Skip to content

Commit

Permalink
Marked files for translation (actualbudget#3548)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-gradina authored Nov 19, 2024
1 parent 5cf4398 commit b4d2d6a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 54 deletions.
49 changes: 28 additions & 21 deletions packages/desktop-client/src/components/reports/DateRange.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { type ReactElement } from 'react';
import { Trans } from 'react-i18next';

import * as d from 'date-fns';

Expand Down Expand Up @@ -36,39 +37,45 @@ export function DateRange({ start, end, type }: DateRangeProps): ReactElement {
} else {
return (
<Text style={{ ...styles.mediumText, color: theme.errorText }}>
There was a problem loading your date range
<Trans>There was a problem loading your date range</Trans>
</Text>
);
}

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 = (
<div>
Compare {d.format(startDate, 'MMM yyyy')} to{' '}
{type === 'budget' ? 'budgeted' : 'average'}
</div>
);
} else if (startDate.getFullYear() !== endDate.getFullYear()) {
content = (
<div>
{type && 'Compare '}
{d.format(startDate, 'MMM yyyy')}
{type ? ' to ' : ' - '}
{['budget', 'average'].includes(type || '')
? type
: d.format(endDate, 'MMM yyyy')}
<Trans>
Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
</Trans>
</div>
);
} else if (startDate.getMonth() !== endDate.getMonth()) {
} else if (
startDate.getFullYear() !== endDate.getFullYear() ||
startDate.getMonth() !== endDate.getMonth()
) {
content = (
<div>
{type && 'Compare '}
{d.format(startDate, 'MMM yyyy')}
{type ? ' to ' : ' - '}
{['budget', 'average'].includes(type || '')
? type
: d.format(endDate, 'MMM yyyy')}
{type ? (
<Trans>
Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
</Trans>
) : (
<Trans>
{{ formattedStartDate }} - {{ formattedEndDate }}
</Trans>
)}
</div>
);
} else {
Expand Down
48 changes: 25 additions & 23 deletions packages/desktop-client/src/components/reports/ReportOptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { t } from 'i18next';

import * as monthUtils from 'loot-core/src/shared/months';
import {
type CustomReportEntity,
Expand Down Expand Up @@ -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 = [
Expand All @@ -59,7 +61,7 @@ export type dateRangeProps = {

const dateRangeOptions: dateRangeProps[] = [
{
description: 'This week',
description: t('This week'),
name: 0,
type: 'Week',
Daily: true,
Expand All @@ -68,7 +70,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Last week',
description: t('Last week'),
name: 1,
type: 'Week',
Daily: true,
Expand All @@ -77,7 +79,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'This month',
description: t('This month'),
name: 0,
type: 'Month',
Daily: true,
Expand All @@ -86,7 +88,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Last month',
description: t('Last month'),
name: 1,
type: 'Month',
Daily: true,
Expand All @@ -95,7 +97,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Last 3 months',
description: t('Last 3 months'),
name: 3,
type: 'Month',
Daily: true,
Expand All @@ -104,7 +106,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Last 6 months',
description: t('Last 6 months'),
name: 6,
type: 'Month',
Daily: false,
Expand All @@ -113,7 +115,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Last 12 months',
description: t('Last 12 months'),
name: 12,
type: 'Month',
Daily: false,
Expand All @@ -122,7 +124,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: false,
},
{
description: 'Year to date',
description: t('Year to date'),
name: 'yearToDate',
type: 'Month',
Daily: false,
Expand All @@ -131,7 +133,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: true,
},
{
description: 'Last year',
description: t('Last year'),
name: 'lastYear',
type: 'Month',
Daily: false,
Expand All @@ -140,7 +142,7 @@ const dateRangeOptions: dateRangeProps[] = [
Yearly: true,
},
{
description: 'All time',
description: t('All time'),
name: 'allTime',
type: 'Month',
Daily: false,
Expand All @@ -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',
Expand Down Expand Up @@ -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,
};
Expand All @@ -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',
Expand Down
20 changes: 11 additions & 9 deletions packages/desktop-client/src/components/reports/disabledList.ts
Original file line number Diff line number Diff line change
@@ -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,
},
];
Expand Down
6 changes: 5 additions & 1 deletion packages/desktop-client/src/components/reports/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<View style={{ flex: 1 }} data-testid="reports-page">
<LoadComponent
name="ReportRouter"
message="Loading reports..."
message={t('Loading reports...')}
importer={() =>
import(/* webpackChunkName: 'reports' */ './ReportRouter')
}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3548.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [a-gradina]
---

Support translations in various files.

0 comments on commit b4d2d6a

Please sign in to comment.