diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index c75cb12634..f9b11f80c7 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -35,6 +35,7 @@ "add_role_and_department": "", "add_to_tag": "", "add_your_first_group_member_now": "", + "added_by_on": "", "adding": "", "additional_licenses": "", "address_line_1": "", @@ -195,6 +196,7 @@ "delete_token": "", "delete_your_account": "", "deleted_at": "", + "deleted_by_on": "", "deleting": "", "demonstrating_git_integration": "", "department": "", diff --git a/services/web/frontend/js/features/history/components/diff-view/diff-view.tsx b/services/web/frontend/js/features/history/components/diff-view/diff-view.tsx index abcdd9509d..4d29613a28 100644 --- a/services/web/frontend/js/features/history/components/diff-view/diff-view.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/diff-view.tsx @@ -7,10 +7,12 @@ import { diffDoc } from '../../services/api' import { highlightsFromDiffResponse } from '../../utils/highlights-from-diff-response' import useAsync from '../../../../shared/hooks/use-async' import ErrorMessage from '../error-message' +import { useTranslation } from 'react-i18next' function DiffView() { const { selection, projectId, loadingFileDiffs } = useHistoryContext() const { isLoading, data, runAsync, error } = useAsync() + const { t } = useTranslation() const { updateRange, selectedFile } = selection useEffect(() => { @@ -34,7 +36,7 @@ function DiffView() { } else { diff = { binary: false, - docDiff: highlightsFromDiffResponse(data.diff), + docDiff: highlightsFromDiffResponse(data.diff, t), } } diff --git a/services/web/frontend/js/features/history/utils/highlights-from-diff-response.ts b/services/web/frontend/js/features/history/utils/highlights-from-diff-response.ts index ecfde4c53f..4238d982fe 100644 --- a/services/web/frontend/js/features/history/utils/highlights-from-diff-response.ts +++ b/services/web/frontend/js/features/history/utils/highlights-from-diff-response.ts @@ -2,8 +2,12 @@ import displayNameForUser from '../../../ide/history/util/displayNameForUser' import moment from 'moment/moment' import ColorManager from '../../../ide/colors/ColorManager' import { DocDiffChunk, Highlight } from '../services/types/doc' +import { TFunction } from 'react-i18next' -export function highlightsFromDiffResponse(chunks: DocDiffChunk[]) { +export function highlightsFromDiffResponse( + chunks: DocDiffChunk[], + t: TFunction<'translation'> // Must be called `t` for i18next-scanner to find calls to it +) { let pos = 0 const highlights: Highlight[] = [] let doc = '' @@ -31,7 +35,7 @@ export function highlightsFromDiffResponse(chunks: DocDiffChunk[]) { highlights.push({ type: 'addition', // There doesn't seem to be a convenient way to make this translatable - label: `Added by ${name} on ${date}`, + label: t('added_by_on', { name, date }), range, hue: ColorManager.getHueForUserId(user?.id), }) @@ -39,7 +43,7 @@ export function highlightsFromDiffResponse(chunks: DocDiffChunk[]) { highlights.push({ type: 'deletion', // There doesn't seem to be a convenient way to make this translatable - label: `Deleted by ${name} on ${date}`, + label: t('deleted_by_on', { name, date }), range, hue: ColorManager.getHueForUserId(user?.id), }) diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 69b241317f..ca65d7440d 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -66,6 +66,7 @@ "add_your_comment_here": "Add your comment here", "add_your_first_group_member_now": "Add your first group members now", "added": "added", + "added_by_on": "Added by __name__ on __date__", "adding": "Adding", "additional_licenses": "Your subscription includes <0>__additionalLicenses__ additional license(s) for a total of <1>__totalLicenses__ licenses.", "address": "Address", @@ -344,6 +345,7 @@ "delete_token": "Delete token", "delete_your_account": "Delete your account", "deleted_at": "Deleted At", + "deleted_by_on": "Deleted by __name__ on __date__", "deleted_files": "Deleted Files", "deleting": "Deleting", "demonstrating_git_integration": "Demonstrating Git integration",