Skip to content

Commit 0ef78e9

Browse files
authored
Merge pull request #2 from matt-fidd/openid_squashed
Translations for OpenID change
2 parents 7145727 + 21a3817 commit 0ef78e9

23 files changed

+380
-237
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ function AppInner() {
132132
addNotification({
133133
type: 'error',
134134
id: 'login-expired',
135-
title: 'Login expired',
135+
title: t('Login expired'),
136136
sticky: true,
137-
message: 'Login expired, please login again.',
137+
message: t('Login expired, please login again.'),
138138
button: {
139-
title: 'Go to login',
139+
title: t('Go to login'),
140140
action: signOut,
141141
},
142142
});

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ export function LoggedInUser({
209209

210210
{!loading && multiuserEnabled && userData?.userName && (
211211
<small>
212-
(logged as: <span>{userData?.displayName}</span>)
212+
<Trans>
213+
(logged in as: <span>{userData?.displayName}</span>)
214+
</Trans>
213215
</small>
214216
)}
215217

packages/desktop-client/src/components/admin/UserAccess/UserAccess.tsx

+15-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React, {
99
useRef,
1010
type CSSProperties,
1111
} from 'react';
12+
import { Trans, useTranslation } from 'react-i18next';
1213
import { useDispatch } from 'react-redux';
1314

1415
import { addNotification, pushModal } from 'loot-core/client/actions';
@@ -42,6 +43,8 @@ function UserAccessContent({
4243
isModal,
4344
setLoading,
4445
}: ManageUserAccessContentProps) {
46+
const { t } = useTranslation();
47+
4548
const [allAccess, setAllAccess] = useState([]);
4649
const [page, setPage] = useState(0);
4750
const [filter, setFilter] = useState('');
@@ -89,7 +92,7 @@ function UserAccessContent({
8992
addNotification({
9093
type: 'error',
9194
id: 'error',
92-
title: 'Error getting available users',
95+
title: t('Error getting available users'),
9396
sticky: true,
9497
message: data.error,
9598
});
@@ -168,19 +171,21 @@ function UserAccessContent({
168171
}}
169172
>
170173
<Text>
171-
Determine which users can view and manage your budgets..{' '}
172-
<Link
173-
variant="external"
174-
to="https://actualbudget.org/docs/budgeting/users-access/"
175-
linkColor="muted"
176-
>
177-
Learn more
178-
</Link>
174+
<Trans>
175+
Determine which users can view and manage your budgets..{' '}
176+
<Link
177+
variant="external"
178+
to="https://actualbudget.org/docs/budgeting/users-access/"
179+
linkColor="muted"
180+
>
181+
Learn more
182+
</Link>
183+
</Trans>
179184
</Text>
180185
</View>
181186
<View style={{ flex: 1 }} />
182187
<Search
183-
placeholder="Filter users..."
188+
placeholder={t('Filter users...')}
184189
value={filter}
185190
onChange={onSearchChange}
186191
/>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
23

34
import { Cell, TableHeader } from '../../table';
45

56
export function UserAccessHeader() {
7+
const { t } = useTranslation();
8+
69
return (
710
<TableHeader>
8-
<Cell value="Access" width={100} style={{ paddingLeft: 15 }} />
9-
<Cell value="User" width="flex" />
10-
<Cell value="Owner" width={100} />
11+
<Cell value={t('Access')} width={100} style={{ paddingLeft: 15 }} />
12+
<Cell value={t('User')} width="flex" />
13+
<Cell value={t('Owner')} width={100} />
1114
</TableHeader>
1215
);
1316
}

packages/desktop-client/src/components/admin/UserAccess/UserAccessPage.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
23

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

56
import { UserAccess } from './UserAccess';
67

78
export function UserAccessPage() {
9+
const { t } = useTranslation();
10+
811
return (
912
<Page
10-
header="User Access"
13+
header={t('User Access')}
1114
style={{
1215
borderRadius: '5px',
1316
marginBottom: '25px',

packages/desktop-client/src/components/admin/UserAccess/UserAccessRow.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-strict-ignore
22
import React, { memo, useState } from 'react';
3+
import { useTranslation } from 'react-i18next';
34

45
import { send } from 'loot-core/platform/client/fetch';
56
import { getUserAccessErrors } from 'loot-core/shared/errors';
@@ -20,6 +21,8 @@ type UserAccessProps = {
2021

2122
export const UserAccessRow = memo(
2223
({ access, hovered, onHover }: UserAccessProps) => {
24+
const { t } = useTranslation();
25+
2326
const backgroundFocus = hovered;
2427
const [marked, setMarked] = useState(
2528
access.owner === 1 || access.haveAccess === 1,
@@ -47,8 +50,10 @@ export const UserAccessRow = memo(
4750
if (someDeletionsFailed) {
4851
actions.addNotification({
4952
type: 'error',
50-
title: 'Access Revocation Incomplete',
51-
message: 'Some access permissions were not revoked successfully.',
53+
title: t('Access Revocation Incomplete'),
54+
message: t(
55+
'Some access permissions were not revoked successfully.',
56+
),
5257
sticky: true,
5358
});
5459
}
@@ -61,11 +66,11 @@ export const UserAccessRow = memo(
6166
actions.addNotification({
6267
type: 'error',
6368
id: 'login-expired',
64-
title: 'Login expired',
69+
title: t('Login expired'),
6570
sticky: true,
6671
message: getUserAccessErrors(error),
6772
button: {
68-
title: 'Go to login',
73+
title: t('Go to login'),
6974
action: () => {
7075
actions.signOut();
7176
},
@@ -74,7 +79,7 @@ export const UserAccessRow = memo(
7479
} else {
7580
actions.addNotification({
7681
type: 'error',
77-
title: 'Something happened while editing access',
82+
title: t('Something happened while editing access'),
7883
sticky: true,
7984
message: getUserAccessErrors(error),
8085
});

packages/desktop-client/src/components/admin/UserDirectory/UserDirectory.tsx

+58-34
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type Dispatch,
99
type CSSProperties,
1010
} from 'react';
11+
import { Trans, useTranslation } from 'react-i18next';
1112
import { useDispatch } from 'react-redux';
1213

1314
import { pushModal } from 'loot-core/src/client/actions/modals';
@@ -37,37 +38,58 @@ type ManageUserDirectoryContentProps = {
3738
setLoading?: Dispatch<SetStateAction<boolean>>;
3839
};
3940

40-
function getUserDirectoryErrors(reason) {
41-
switch (reason) {
42-
case 'unauthorized':
43-
return 'You are not logged in.';
44-
case 'token-expired':
45-
return 'Login expired, please login again.';
46-
case 'user-cant-be-empty':
47-
return 'Please enter a value for the username; the field cannot be empty.';
48-
case 'role-cant-be-empty':
49-
return 'Select a role; the field cannot be empty.';
50-
case 'user-already-exists':
51-
return 'The username you entered already exists. Please choose a different username.';
52-
case 'not-all-deleted':
53-
return 'Not all users were deleted. Check if one of the selected users is the server owner.';
54-
case 'role-does-not-exists':
55-
return 'Selected role does not exists, possibly a bug? Visit https://actualbudget.org/contact/ for support.';
56-
default:
57-
return `An internal error occurred, sorry! Visit https://actualbudget.org/contact/ for support. (ref: ${reason})`;
41+
function useGetUserDirectoryErrors() {
42+
const { t } = useTranslation();
43+
44+
function getUserDirectoryErrors(reason) {
45+
switch (reason) {
46+
case 'unauthorized':
47+
return t('You are not logged in.');
48+
case 'token-expired':
49+
return t('Login expired, please login again.');
50+
case 'user-cant-be-empty':
51+
return t(
52+
'Please enter a value for the username; the field cannot be empty.',
53+
);
54+
case 'role-cant-be-empty':
55+
return t('Select a role; the field cannot be empty.');
56+
case 'user-already-exists':
57+
return t(
58+
'The username you entered already exists. Please choose a different username.',
59+
);
60+
case 'not-all-deleted':
61+
return t(
62+
'Not all users were deleted. Check if one of the selected users is the server owner.',
63+
);
64+
case 'role-does-not-exists':
65+
return t(
66+
'Selected role does not exists, possibly a bug? Visit https://actualbudget.org/contact/ for support.',
67+
);
68+
default:
69+
return t(
70+
'An internal error occurred, sorry! Visit https://actualbudget.org/contact/ for support. (ref: {{reason}})',
71+
{ reason },
72+
);
73+
}
5874
}
75+
76+
return { getUserDirectoryErrors };
5977
}
6078

6179
function UserDirectoryContent({
6280
isModal,
6381
setLoading,
6482
}: ManageUserDirectoryContentProps) {
83+
const { t } = useTranslation();
84+
6585
const [allUsers, setAllUsers] = useState([]);
6686
const [page, setPage] = useState(0);
6787
const [filter, setFilter] = useState('');
6888
const dispatch = useDispatch();
6989
const actions = useActions();
7090

91+
const { getUserDirectoryErrors } = useGetUserDirectoryErrors();
92+
7193
const filteredUsers = useMemo(() => {
7294
return (
7395
filter === ''
@@ -127,18 +149,18 @@ function UserDirectoryContent({
127149
actions.addNotification({
128150
type: 'error',
129151
id: 'login-expired',
130-
title: 'Login expired',
152+
title: t('Login expired'),
131153
sticky: true,
132154
message: getUserDirectoryErrors(error),
133155
button: {
134-
title: 'Go to login',
156+
title: t('Go to login'),
135157
action: () => actions.signOut(),
136158
},
137159
});
138160
} else {
139161
actions.addNotification({
140162
type: 'error',
141-
title: 'Something happened while deleting users',
163+
title: t('Something happened while deleting users'),
142164
sticky: true,
143165
message: getUserDirectoryErrors(error),
144166
});
@@ -208,20 +230,22 @@ function UserDirectoryContent({
208230
}}
209231
>
210232
<Text>
211-
Manage and view users who can create new budgets or be invited to
212-
access existing ones.{' '}
213-
<Link
214-
variant="external"
215-
to="https://actualbudget.org/docs/budgeting/users/"
216-
linkColor="muted"
217-
>
218-
Learn more
219-
</Link>
233+
<Trans>
234+
Manage and view users who can create new budgets or be invited
235+
to access existing ones.{' '}
236+
<Link
237+
variant="external"
238+
to="https://actualbudget.org/docs/budgeting/users/"
239+
linkColor="muted"
240+
>
241+
Learn more
242+
</Link>
243+
</Trans>
220244
</Text>
221245
</View>
222246
<View style={{ flex: 1 }} />
223247
<Search
224-
placeholder="Filter users..."
248+
placeholder={t('Filter users...')}
225249
value={filter}
226250
onChange={onSearchChange}
227251
/>
@@ -235,7 +259,7 @@ function UserDirectoryContent({
235259
style={{ marginBottom: -1 }}
236260
>
237261
{filteredUsers.length === 0 ? (
238-
<EmptyMessage text="No users" style={{ marginTop: 15 }} />
262+
<EmptyMessage text={t('No users')} style={{ marginTop: 15 }} />
239263
) : (
240264
<UsersList
241265
users={filteredUsers}
@@ -258,11 +282,11 @@ function UserDirectoryContent({
258282
<Stack direction="row" align="center" justify="flex-end" spacing={2}>
259283
{selectedInst.items.size > 0 && (
260284
<Button onPress={onDeleteSelected}>
261-
Delete {selectedInst.items.size} users
285+
<Trans> Delete {selectedInst.items.size} users </Trans>
262286
</Button>
263287
)}
264288
<Button variant="primary" onPress={onAddUser}>
265-
Add new user
289+
<Trans>Add new user</Trans>
266290
</Button>
267291
</Stack>
268292
</View>

packages/desktop-client/src/components/admin/UserDirectory/UserDirectoryHeader.tsx

+8-5
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 {
45
useSelectedItems,
@@ -7,6 +8,8 @@ import {
78
import { SelectCell, Cell, TableHeader } from '../../table';
89

910
export function UserDirectoryHeader() {
11+
const { t } = useTranslation();
12+
1013
const selectedItems = useSelectedItems();
1114
const dispatchSelected = useSelectedDispatch();
1215

@@ -20,11 +23,11 @@ export function UserDirectoryHeader() {
2023
dispatchSelected({ type: 'select-all', isRangeSelect: e.shiftKey })
2124
}
2225
/>
23-
<Cell value="Username" width="flex" />
24-
<Cell value="Display Name" width={250} />
25-
<Cell value="Role" width={100} />
26-
<Cell value="Enabled" width={100} />
27-
<Cell value="Server Owner" width={100} />
26+
<Cell value={t('Username')} width="flex" />
27+
<Cell value={t('Display Name')} width={250} />
28+
<Cell value={t('Role')} width={100} />
29+
<Cell value={t('Enabled')} width={100} />
30+
<Cell value={t('Server Owner')} width={100} />
2831
<Cell value="" width={80} />
2932
</TableHeader>
3033
);

packages/desktop-client/src/components/admin/UserDirectory/UserDirectoryPage.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { type ReactNode } from 'react';
2+
import { Trans, useTranslation } from 'react-i18next';
23

34
import { useNavigate } from '../../../hooks/useNavigate';
45
import { Button } from '../../common/Button2';
@@ -12,9 +13,11 @@ export function UserDirectoryPage({
1213
}: {
1314
bottomContent?: ReactNode;
1415
}) {
16+
const { t } = useTranslation();
17+
1518
return (
1619
<Page
17-
header="User Directory"
20+
header={t('User Directory')}
1821
style={{
1922
borderRadius: '5px',
2023
marginBottom: '25px',
@@ -40,7 +43,7 @@ export function BackToFileListButton() {
4043

4144
return (
4245
<Button style={{ maxWidth: '200px' }} onPress={() => navigate('/')}>
43-
Back to file list
46+
<Trans>Back to file list</Trans>
4447
</Button>
4548
);
4649
}

0 commit comments

Comments
 (0)