Skip to content

Commit f4fd4f1

Browse files
CopilotCopilot
andcommitted
refactor(plugin-detail): replace hardcoded English strings in DiffView with i18n translation calls
- Import useDetailTranslation hook - Replace 'Unified diff', 'Side-by-side diff', 'No changes', 'Previous', 'Current' with t() calls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f7fc2d4 commit f4fd4f1

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

packages/plugin-detail/src/DiffView.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import * as React from 'react';
1010
import { cn, Button, Card, CardHeader, CardTitle, CardContent } from '@object-ui/components';
1111
import { Columns2, Rows3 } from 'lucide-react';
12+
import { useDetailTranslation } from './useDetailTranslation';
1213

1314
export type DiffFieldType = 'string' | 'number' | 'boolean' | 'json' | 'date';
1415
export type DiffMode = 'unified' | 'side-by-side';
@@ -98,6 +99,7 @@ export const DiffView: React.FC<DiffViewProps> = ({
9899
mode: initialMode = 'unified',
99100
className,
100101
}) => {
102+
const { t } = useDetailTranslation();
101103
const [mode, setMode] = React.useState<DiffMode>(initialMode);
102104

103105
const oldLines = React.useMemo(() => valueToLines(oldValue, fieldType), [oldValue, fieldType]);
@@ -146,7 +148,7 @@ export const DiffView: React.FC<DiffViewProps> = ({
146148
size="icon"
147149
className="h-7 w-7"
148150
onClick={() => setMode('unified')}
149-
title="Unified diff"
151+
title={t('detail.unifiedDiff')}
150152
>
151153
<Rows3 className="h-3.5 w-3.5" />
152154
</Button>
@@ -155,7 +157,7 @@ export const DiffView: React.FC<DiffViewProps> = ({
155157
size="icon"
156158
className="h-7 w-7"
157159
onClick={() => setMode('side-by-side')}
158-
title="Side-by-side diff"
160+
title={t('detail.sideBySideDiff')}
159161
>
160162
<Columns2 className="h-3.5 w-3.5" />
161163
</Button>
@@ -164,7 +166,7 @@ export const DiffView: React.FC<DiffViewProps> = ({
164166
</CardHeader>
165167
<CardContent className="p-0">
166168
{!hasChanges ? (
167-
<p className="px-4 py-3 text-sm text-muted-foreground">No changes</p>
169+
<p className="px-4 py-3 text-sm text-muted-foreground">{t('detail.noChanges')}</p>
168170
) : mode === 'unified' ? (
169171
/* Unified diff view */
170172
<div className="font-mono text-xs overflow-x-auto">
@@ -192,10 +194,10 @@ export const DiffView: React.FC<DiffViewProps> = ({
192194
<div className="grid grid-cols-2 divide-x font-mono text-xs min-w-0">
193195
{/* Headers */}
194196
<div className="px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50">
195-
Previous
197+
{t('detail.previousVersion')}
196198
</div>
197199
<div className="px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50">
198-
Current
200+
{t('detail.currentVersion')}
199201
</div>
200202
{/* Rows */}
201203
{sideBySidePairs.map((pair, index) => (

packages/plugin-detail/src/RecordComments.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as React from 'react';
1010
import { cn, Button, Card, CardHeader, CardTitle, CardContent } from '@object-ui/components';
1111
import { MessageSquare, Send, Pin, Search, X } from 'lucide-react';
1212
import type { CommentEntry } from '@object-ui/types';
13+
import { useDetailTranslation } from './useDetailTranslation';
1314

1415
export interface RecordCommentsProps {
1516
comments: CommentEntry[];
@@ -50,6 +51,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
5051
searchable = false,
5152
className,
5253
}) => {
54+
const { t } = useDetailTranslation();
5355
const [newComment, setNewComment] = React.useState('');
5456
const [isSubmitting, setIsSubmitting] = React.useState(false);
5557
const [searchQuery, setSearchQuery] = React.useState('');
@@ -98,7 +100,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
98100
<CardHeader>
99101
<CardTitle className="flex items-center gap-2 text-base">
100102
<MessageSquare className="h-4 w-4" />
101-
Comments
103+
{t('detail.comments')}
102104
<span className="text-sm font-normal text-muted-foreground">
103105
({comments.length})
104106
</span>
@@ -112,7 +114,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
112114
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
113115
<input
114116
className="w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
115-
placeholder="Search comments…"
117+
placeholder={t('detail.searchComments')}
116118
value={searchQuery}
117119
onChange={(e) => setSearchQuery(e.target.value)}
118120
aria-label="Search comments"
@@ -136,7 +138,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
136138
<div className="flex gap-2">
137139
<textarea
138140
className="flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none"
139-
placeholder="Add a comment… (Ctrl+Enter to submit)"
141+
placeholder={t('detail.addCommentPlaceholder')}
140142
value={newComment}
141143
onChange={(e) => setNewComment(e.target.value)}
142144
onKeyDown={handleKeyDown}
@@ -157,7 +159,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
157159
{/* Comment List */}
158160
{sortedComments.length === 0 ? (
159161
<p className="text-sm text-muted-foreground text-center py-4">
160-
{searchQuery.trim() ? 'No matching comments' : 'No comments yet'}
162+
{searchQuery.trim() ? t('detail.noMatchingComments') : t('detail.noCommentsYet')}
161163
</p>
162164
) : (
163165
<div className="space-y-3">
@@ -187,7 +189,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
187189
{comment.pinned && (
188190
<span className="text-xs text-amber-600 flex items-center gap-0.5">
189191
<Pin className="h-3 w-3" />
190-
Pinned
192+
{t('detail.pinned')}
191193
</span>
192194
)}
193195
</div>
@@ -201,7 +203,7 @@ export const RecordComments: React.FC<RecordCommentsProps> = ({
201203
aria-label={comment.pinned ? 'Unpin comment' : 'Pin comment'}
202204
>
203205
<Pin className="h-3 w-3" />
204-
{comment.pinned ? 'Unpin' : 'Pin'}
206+
{comment.pinned ? t('detail.unpin') : t('detail.pin')}
205207
</button>
206208
)}
207209
</div>

0 commit comments

Comments
 (0)