Skip to content

Commit 4d30cc9

Browse files
committed
Add translation values to activity log output
1 parent 06427f8 commit 4d30cc9

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

resources/lang/en/activity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
'delete' => 'Deleted API key <strong>:identifier</strong>',
2727
],
2828
'ssh-key' => [
29-
'create' => 'Added SSH key (<strong>:fingerprint</strong>) to account',
30-
'delete' => 'Removed SSH key (<strong>:fingerprint</strong>) from account',
29+
'create' => 'Added SSH key <strong>:fingerprint</strong> to account',
30+
'delete' => 'Removed SSH key <strong>:fingerprint</strong> from account',
3131
],
3232
'two-factor' => [
3333
'create' => 'Enabled two-factor authentication for account',

resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import { useLocation } from 'react-router';
1313
import Spinner from '@/components/elements/Spinner';
1414
import { styles as btnStyles } from '@/components/elements/button/index';
1515
import classNames from 'classnames';
16+
import Translate from '@/components/elements/Translate';
1617

1718
export default () => {
1819
const location = useLocation();
20+
1921
const { clearAndAddHttpError } = useFlashKey('account');
2022
const [ filters, setFilters ] = useState<ActivityLogFilters>({ page: 1, sorts: { timestamp: -1 } });
2123
const { data, isValidating, error } = useActivityLogs(filters, {
@@ -90,6 +92,11 @@ export default () => {
9092
</Tooltip>
9193
}
9294
</div>
95+
<p className={'mt-1 text-sm'}>
96+
<Translate ns={'activity'} values={activity.properties}>
97+
{activity.event.replace(':', '.')}
98+
</Translate>
99+
</p>
93100
<div className={'mt-1 flex items-center text-sm'}>
94101
<Link
95102
to={`?${queryTo({ ip: activity.ip })}`}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { Trans, TransProps, useTranslation } from 'react-i18next';
3+
4+
type Props = Omit<TransProps, 't'>;
5+
6+
export default ({ ns, children, ...props }: Props) => {
7+
const { t } = useTranslation(ns);
8+
9+
return (
10+
<Trans t={t} {...props}>
11+
{children}
12+
</Trans>
13+
);
14+
};

resources/scripts/i18n.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ i18n
1919
backend: {
2020
backend: I18NextHttpBackend,
2121
backendOption: {
22-
loadPath: `/locales/locale.json?locale={{lng}}&namespace={{ns}}&hash=${hash}`,
22+
loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
23+
queryStringParams: { hash },
2324
allowMultiLoading: true,
2425
} as BackendOptions,
2526
} as Record<string, any>,
@@ -30,6 +31,4 @@ i18n
3031
},
3132
});
3233

33-
i18n.loadNamespaces([ 'validation' ]).catch(console.error);
34-
3534
export default i18n;

0 commit comments

Comments
 (0)