Add translation values to activity log output

This commit is contained in:
DaneEveritt 2022-06-11 14:52:41 -04:00
parent 06427f8d13
commit 4d30cc9e7e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 25 additions and 5 deletions

View file

@ -26,8 +26,8 @@ return [
'delete' => 'Deleted API key <strong>:identifier</strong>', 'delete' => 'Deleted API key <strong>:identifier</strong>',
], ],
'ssh-key' => [ 'ssh-key' => [
'create' => 'Added SSH key (<strong>:fingerprint</strong>) to account', 'create' => 'Added SSH key <strong>:fingerprint</strong> to account',
'delete' => 'Removed SSH key (<strong>:fingerprint</strong>) from account', 'delete' => 'Removed SSH key <strong>:fingerprint</strong> from account',
], ],
'two-factor' => [ 'two-factor' => [
'create' => 'Enabled two-factor authentication for account', 'create' => 'Enabled two-factor authentication for account',

View file

@ -13,9 +13,11 @@ import { useLocation } from 'react-router';
import Spinner from '@/components/elements/Spinner'; import Spinner from '@/components/elements/Spinner';
import { styles as btnStyles } from '@/components/elements/button/index'; import { styles as btnStyles } from '@/components/elements/button/index';
import classNames from 'classnames'; import classNames from 'classnames';
import Translate from '@/components/elements/Translate';
export default () => { export default () => {
const location = useLocation(); const location = useLocation();
const { clearAndAddHttpError } = useFlashKey('account'); const { clearAndAddHttpError } = useFlashKey('account');
const [ filters, setFilters ] = useState<ActivityLogFilters>({ page: 1, sorts: { timestamp: -1 } }); const [ filters, setFilters ] = useState<ActivityLogFilters>({ page: 1, sorts: { timestamp: -1 } });
const { data, isValidating, error } = useActivityLogs(filters, { const { data, isValidating, error } = useActivityLogs(filters, {
@ -90,6 +92,11 @@ export default () => {
</Tooltip> </Tooltip>
} }
</div> </div>
<p className={'mt-1 text-sm'}>
<Translate ns={'activity'} values={activity.properties}>
{activity.event.replace(':', '.')}
</Translate>
</p>
<div className={'mt-1 flex items-center text-sm'}> <div className={'mt-1 flex items-center text-sm'}>
<Link <Link
to={`?${queryTo({ ip: activity.ip })}`} to={`?${queryTo({ ip: activity.ip })}`}

View file

@ -0,0 +1,14 @@
import React from 'react';
import { Trans, TransProps, useTranslation } from 'react-i18next';
type Props = Omit<TransProps, 't'>;
export default ({ ns, children, ...props }: Props) => {
const { t } = useTranslation(ns);
return (
<Trans t={t} {...props}>
{children}
</Trans>
);
};

View file

@ -19,7 +19,8 @@ i18n
backend: { backend: {
backend: I18NextHttpBackend, backend: I18NextHttpBackend,
backendOption: { backendOption: {
loadPath: `/locales/locale.json?locale={{lng}}&namespace={{ns}}&hash=${hash}`, loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
queryStringParams: { hash },
allowMultiLoading: true, allowMultiLoading: true,
} as BackendOptions, } as BackendOptions,
} as Record<string, any>, } as Record<string, any>,
@ -30,6 +31,4 @@ i18n
}, },
}); });
i18n.loadNamespaces([ 'validation' ]).catch(console.error);
export default i18n; export default i18n;