mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 23:35:31 +00:00
Merge pull request #13093 from overleaf/td-history-cm6-translations
History migration: Use translatable strings in history diff highlight tooltips GitOrigin-RevId: 90c127b792c116c5805ee191b80564eb763cee44
This commit is contained in:
parent
6b78c3025a
commit
ebbb4fd6d0
4 changed files with 14 additions and 4 deletions
|
@ -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": "",
|
||||
|
|
|
@ -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<DocDiffResponse>()
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -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__</0> additional license(s) for a total of <1>__totalLicenses__</1> 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",
|
||||
|
|
Loading…
Add table
Reference in a new issue