Skip to content

Commit d08be58

Browse files
authored
Marked files for translation (#3827)
* Add translation files for desktop client * Add backend translation files for i18n integration * code refactored * code refactored * code refactored
1 parent db68170 commit d08be58

File tree

14 files changed

+162
-100
lines changed

14 files changed

+162
-100
lines changed

packages/desktop-client/src/components/Modals.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-strict-ignore
22
import React, { useEffect } from 'react';
3+
import { useTranslation } from 'react-i18next';
34
import { useDispatch } from 'react-redux';
45
import { useLocation } from 'react-router-dom';
56

@@ -81,6 +82,8 @@ export function Modals() {
8182
}
8283
}, [location]);
8384

85+
const { t } = useTranslation();
86+
8487
const modals = modalStack
8588
.map(({ name, options }) => {
8689
switch (name) {
@@ -287,10 +290,12 @@ export function Modals() {
287290
Header={props => (
288291
<ModalHeader
289292
{...props}
290-
title={<ModalTitle title="New Category" shrinkOnOverflow />}
293+
title={
294+
<ModalTitle title={t('New Category')} shrinkOnOverflow />
295+
}
291296
/>
292297
)}
293-
inputPlaceholder="Category name"
298+
inputPlaceholder={t('Category name')}
294299
buttonText="Add"
295300
onValidate={options.onValidate}
296301
onSubmit={options.onSubmit}
@@ -306,12 +311,15 @@ export function Modals() {
306311
<ModalHeader
307312
{...props}
308313
title={
309-
<ModalTitle title="New Category Group" shrinkOnOverflow />
314+
<ModalTitle
315+
title={t('New Category Group')}
316+
shrinkOnOverflow
317+
/>
310318
}
311319
/>
312320
)}
313-
inputPlaceholder="Category group name"
314-
buttonText="Add"
321+
inputPlaceholder={t('Category group name')}
322+
buttonText={t('Add')}
315323
onValidate={options.onValidate}
316324
onSubmit={options.onSubmit}
317325
/>

packages/desktop-client/src/components/modals/BudgetPageMenuModal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {
22
type ComponentPropsWithoutRef,
33
type CSSProperties,
44
} from 'react';
5+
import { useTranslation } from 'react-i18next';
56

67
import { useLocalPref } from '../../hooks/useLocalPref';
78
import { theme, styles } from '../../style';
@@ -77,6 +78,7 @@ function BudgetPageMenu({
7778
throw new Error(`Unrecognized menu item: ${name}`);
7879
}
7980
};
81+
const { t } = useTranslation();
8082

8183
return (
8284
<Menu
@@ -85,15 +87,15 @@ function BudgetPageMenu({
8587
items={[
8688
{
8789
name: 'add-category-group',
88-
text: 'Add category group',
90+
text: t('Add category group'),
8991
},
9092
{
9193
name: 'toggle-hidden-categories',
92-
text: `${!showHiddenCategories ? 'Show' : 'Hide'} hidden categories`,
94+
text: `${!showHiddenCategories ? t('Show') : t('Hide')} ${t('hidden categories')}`,
9395
},
9496
{
9597
name: 'switch-budget-file',
96-
text: 'Switch budget file',
98+
text: t('Switch budget file'),
9799
},
98100
]}
99101
/>

packages/desktop-client/src/components/payees/ManagePayeesPage.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
23
import { useLocation } from 'react-router-dom';
34

45
import { Page } from '../Page';
56

67
import { ManagePayeesWithData } from './ManagePayeesWithData';
78

89
export function ManagePayeesPage() {
10+
const { t } = useTranslation();
911
const location = useLocation();
1012
return (
11-
<Page header="Payees">
13+
<Page header={t('Payees')}>
1214
<ManagePayeesWithData
1315
initialSelectedIds={
1416
location.state && location.state.selectedPayee

packages/desktop-client/src/components/reports/SaveReportChoose.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { createRef, useEffect, useState } from 'react';
22
import { Form } from 'react-aria-components';
3+
import { useTranslation } from 'react-i18next';
34

45
import { theme } from '../../style/theme';
56
import { Button } from '../common/Button2';
@@ -16,6 +17,7 @@ export function SaveReportChoose({ onApply }: SaveReportChooseProps) {
1617
const inputRef = createRef<HTMLInputElement>();
1718
const [err, setErr] = useState('');
1819
const [value, setValue] = useState('');
20+
const { t } = useTranslation();
1921

2022
useEffect(() => {
2123
if (inputRef.current) {
@@ -38,7 +40,9 @@ export function SaveReportChoose({ onApply }: SaveReportChooseProps) {
3840
}}
3941
>
4042
<View style={{ flexDirection: 'row', align: 'center' }}>
41-
<Text style={{ userSelect: 'none', flex: 1 }}>Choose Report</Text>
43+
<Text style={{ userSelect: 'none', flex: 1 }}>
44+
{t('Choose Report')}
45+
</Text>
4246
<View style={{ flex: 1 }} />
4347
</View>
4448
<GenericInput
@@ -60,7 +64,7 @@ export function SaveReportChoose({ onApply }: SaveReportChooseProps) {
6064
>
6165
<View style={{ flex: 1 }} />
6266
<Button variant="primary" type="submit">
63-
Apply
67+
{t('Apply')}
6468
</Button>
6569
</Stack>
6670
</Form>

packages/desktop-client/src/components/reports/SaveReportMenu.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
23

34
import { Menu, type MenuItem } from '../common/Menu';
45

@@ -11,45 +12,46 @@ export function SaveReportMenu({
1112
savedStatus: string;
1213
listReports: number;
1314
}) {
15+
const { t } = useTranslation();
1416
const savedMenu: MenuItem[] =
1517
savedStatus === 'saved'
1618
? [
17-
{ name: 'rename-report', text: 'Rename' },
18-
{ name: 'delete-report', text: 'Delete' },
19+
{ name: 'rename-report', text: t('Rename') },
20+
{ name: 'delete-report', text: t('Delete') },
1921
Menu.line,
2022
]
2123
: [];
2224

2325
const modifiedMenu: MenuItem[] =
2426
savedStatus === 'modified'
2527
? [
26-
{ name: 'rename-report', text: 'Rename' },
28+
{ name: 'rename-report', text: t('Rename') },
2729
{
2830
name: 'update-report',
29-
text: 'Update report',
31+
text: t('Update report'),
3032
},
3133
{
3234
name: 'reload-report',
33-
text: 'Revert changes',
35+
text: t('Revert changes'),
3436
},
35-
{ name: 'delete-report', text: 'Delete' },
37+
{ name: 'delete-report', text: t('Delete') },
3638
Menu.line,
3739
]
3840
: [];
3941

4042
const unsavedMenu: MenuItem[] = [
4143
{
4244
name: 'save-report',
43-
text: 'Save new report',
45+
text: t('Save new report'),
4446
},
4547
{
4648
name: 'reset-report',
47-
text: 'Reset to default',
49+
text: t('Reset to default'),
4850
},
4951
Menu.line,
5052
{
5153
name: 'choose-report',
52-
text: 'Choose Report',
54+
text: t('Choose Report'),
5355
disabled: listReports > 0 ? false : true,
5456
},
5557
];

packages/desktop-client/src/components/util/DisplayId.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-strict-ignore
22
import React from 'react';
3+
import { useTranslation } from 'react-i18next';
34

45
import { useAccount } from '../../hooks/useAccount';
56
import { usePayee } from '../../hooks/usePayee';
@@ -25,25 +26,27 @@ export function DisplayId({
2526
}
2627

2728
function AccountDisplayId({ id, noneColor }) {
29+
const { t } = useTranslation();
2830
const account = useAccount(id);
2931
return (
3032
<Text
3133
style={account == null ? { color: noneColor } : null}
32-
title={account ? account.name : 'None'}
34+
title={account ? account.name : t('None')}
3335
>
34-
{account ? account.name : 'None'}
36+
{account ? account.name : t('None')}
3537
</Text>
3638
);
3739
}
3840

3941
function PayeeDisplayId({ id, noneColor }) {
42+
const { t } = useTranslation();
4043
const payee = usePayee(id);
4144
return (
4245
<Text
4346
style={payee == null ? { color: noneColor } : null}
44-
title={payee ? payee.name : 'None'}
47+
title={payee ? payee.name : t('None')}
4548
>
46-
{payee ? payee.name : 'None'}
49+
{payee ? payee.name : t('None')}
4750
</Text>
4851
);
4952
}

packages/loot-core/src/server/budget/cleanup-template.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// @ts-strict-ignore
2+
import { t } from 'i18next';
3+
24
import { Notification } from '../../client/state-types/notifications';
35
import * as monthUtils from '../../shared/months';
46
import * as db from '../db';
@@ -113,7 +115,7 @@ async function applyGroupCleanups(
113115
});
114116
}
115117
} else {
116-
warnings.push(groupName + ' has no matching sink categories.');
118+
warnings.push(groupName + t(' has no matching sink categories.'));
117119
}
118120
sourceGroups = sourceGroups.filter(c => c.group !== groupName);
119121
groupLength = sourceGroups.length;
@@ -218,7 +220,7 @@ async function processCleanup(month: string): Promise<Notification> {
218220
});
219221
num_sources += 1;
220222
} else {
221-
warnings.push(category.name + ' does not have available funds.');
223+
warnings.push(category.name + t(' does not have available funds.'));
222224
}
223225
const carryover = await db.first(
224226
`SELECT carryover FROM zero_budgets WHERE month = ? and category = ?`,
@@ -285,7 +287,7 @@ async function processCleanup(month: string): Promise<Notification> {
285287

286288
const budgetAvailable = await getSheetValue(sheetName, `to-budget`);
287289
if (budgetAvailable <= 0) {
288-
warnings.push('Global: No funds are available to reallocate.');
290+
warnings.push(t('Global: No funds are available to reallocate.'));
289291
}
290292

291293
//fill sinking categories
@@ -320,19 +322,19 @@ async function processCleanup(month: string): Promise<Notification> {
320322
return {
321323
type: 'error',
322324
sticky: true,
323-
message: `There were errors interpreting some templates:`,
325+
message: t('There were errors interpreting some templates:'),
324326
pre: errors.join('\n\n'),
325327
};
326328
} else if (warnings.length) {
327329
return {
328330
type: 'warning',
329-
message: 'Global: Funds not available:',
331+
message: t('Global: Funds not available:'),
330332
pre: warnings.join('\n\n'),
331333
};
332334
} else {
333335
return {
334336
type: 'message',
335-
message: 'All categories were up to date.',
337+
message: t('All categories were up to date.'),
336338
};
337339
}
338340
} else {
@@ -342,13 +344,15 @@ async function processCleanup(month: string): Promise<Notification> {
342344
if (errors.length) {
343345
return {
344346
sticky: true,
345-
message: `${applied} There were errors interpreting some templates:`,
347+
message: t('{applied} There were errors interpreting some templates:', {
348+
applied,
349+
}),
346350
pre: errors.join('\n\n'),
347351
};
348352
} else if (warnings.length) {
349353
return {
350354
type: 'warning',
351-
message: 'Global: Funds not available:',
355+
message: t('Global: Funds not available:'),
352356
pre: warnings.join('\n\n'),
353357
};
354358
} else {

packages/loot-core/src/server/budget/goaltemplates.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// @ts-strict-ignore
2+
import { t } from 'i18next';
3+
24
import { Notification } from '../../client/state-types/notifications';
35
import * as monthUtils from '../../shared/months';
46
import * as db from '../db';
@@ -188,13 +190,13 @@ async function processTemplate(
188190
if (catObjects.length === 0 && errors.length === 0) {
189191
return {
190192
type: 'message',
191-
message: 'Everything is up to date',
193+
message: t('Everything is up to date'),
192194
};
193195
}
194196
if (errors.length > 0) {
195197
return {
196198
sticky: true,
197-
message: `There were errors interpreting some templates:`,
199+
message: t('There were errors interpreting some templates:'),
198200
pre: errors.join(`\n\n`),
199201
};
200202
}
@@ -245,6 +247,8 @@ async function processTemplate(
245247

246248
return {
247249
type: 'message',
248-
message: `Successfully applied templates to ${catObjects.length} categories`,
250+
message: t('Successfully applied templates to {length} categories', {
251+
length: catObjects.length,
252+
}),
249253
};
250254
}

packages/loot-core/src/server/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import './polyfills';
33

44
import * as injectAPI from '@actual-app/api/injected';
55
import * as CRDT from '@actual-app/crdt';
6+
import { t } from 'i18next';
67
import { v4 as uuidv4 } from 'uuid';
78

89
import { createTestBudget } from '../mocks/budget';
@@ -1087,14 +1088,18 @@ function handleSyncError(err, acct) {
10871088
accountId: acct.id,
10881089
message: err.reason
10891090
? err.reason
1090-
: `Account “${acct.name}” is not linked properly. Please link it again.`,
1091+
: t(
1092+
'Account “{acctName}” is not linked properly. Please link it again.',
1093+
{ acctName: acct.name },
1094+
),
10911095
};
10921096
}
10931097

10941098
return {
10951099
accountId: acct.id,
1096-
message:
1100+
message: t(
10971101
'There was an internal error. Please get in touch https://actualbudget.org/contact for support.',
1102+
),
10981103
internal: err.stack,
10991104
};
11001105
}

packages/loot-core/src/server/mutators.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// @ts-strict-ignore
2+
import { t } from 'i18next';
3+
24
import { captureException, captureBreadcrumb } from '../platform/exceptions';
35
import { sequential } from '../shared/async';
46
import { type HandlerFunctions, type Handlers } from '../types/handlers';
@@ -121,7 +123,7 @@ export function getMutatorContext() {
121123
if (currentContext == null) {
122124
captureBreadcrumb({
123125
category: 'server',
124-
message: 'Recent methods: ' + _latestHandlerNames.join(', '),
126+
message: t('Recent methods: ') + _latestHandlerNames.join(', '),
125127
});
126128
// captureException(new Error('getMutatorContext: mutator not running'));
127129

0 commit comments

Comments
 (0)