From 4d30cc9e7e90abbbfeab9b863d7423a637bd132c Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sat, 11 Jun 2022 14:52:41 -0400 Subject: [PATCH] Add translation values to activity log output --- resources/lang/en/activity.php | 4 ++-- .../dashboard/activity/ActivityLogContainer.tsx | 7 +++++++ .../scripts/components/elements/Translate.tsx | 14 ++++++++++++++ resources/scripts/i18n.ts | 5 ++--- 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 resources/scripts/components/elements/Translate.tsx diff --git a/resources/lang/en/activity.php b/resources/lang/en/activity.php index 352758c5e..f3e37bb78 100644 --- a/resources/lang/en/activity.php +++ b/resources/lang/en/activity.php @@ -26,8 +26,8 @@ return [ 'delete' => 'Deleted API key :identifier', ], 'ssh-key' => [ - 'create' => 'Added SSH key (:fingerprint) to account', - 'delete' => 'Removed SSH key (:fingerprint) from account', + 'create' => 'Added SSH key :fingerprint to account', + 'delete' => 'Removed SSH key :fingerprint from account', ], 'two-factor' => [ 'create' => 'Enabled two-factor authentication for account', diff --git a/resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx b/resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx index 446490cd8..1e061125c 100644 --- a/resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx +++ b/resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx @@ -13,9 +13,11 @@ import { useLocation } from 'react-router'; import Spinner from '@/components/elements/Spinner'; import { styles as btnStyles } from '@/components/elements/button/index'; import classNames from 'classnames'; +import Translate from '@/components/elements/Translate'; export default () => { const location = useLocation(); + const { clearAndAddHttpError } = useFlashKey('account'); const [ filters, setFilters ] = useState({ page: 1, sorts: { timestamp: -1 } }); const { data, isValidating, error } = useActivityLogs(filters, { @@ -90,6 +92,11 @@ export default () => { } +

+ + {activity.event.replace(':', '.')} + +

; + +export default ({ ns, children, ...props }: Props) => { + const { t } = useTranslation(ns); + + return ( + + {children} + + ); +}; diff --git a/resources/scripts/i18n.ts b/resources/scripts/i18n.ts index 4f68c6175..cc527d5ae 100644 --- a/resources/scripts/i18n.ts +++ b/resources/scripts/i18n.ts @@ -19,7 +19,8 @@ i18n backend: { backend: I18NextHttpBackend, backendOption: { - loadPath: `/locales/locale.json?locale={{lng}}&namespace={{ns}}&hash=${hash}`, + loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}', + queryStringParams: { hash }, allowMultiLoading: true, } as BackendOptions, } as Record, @@ -30,6 +31,4 @@ i18n }, }); -i18n.loadNamespaces([ 'validation' ]).catch(console.error); - export default i18n;