Skip to content

Commit d4535a1

Browse files
committed
Add internationalization support to ResponsePreview component
- 'failed to apply changes to the file' is not translated ├── apps │ └── editor │ └── src │ └── views │ ├── prompt │ │ └── frontend │ │ ├── App.tsx │ │ ├── Prompt.tsx │ │ └── i18n │ │ ├── translations │ │ │ ├── index.ts │ │ │ └── response-preview.ts │ │ └── use-translation.tsx │ └── shared │ └── hooks │ └── use-translation.tsx └── packages └── ui └── src └── components └── editor └── prompt-view └── ResponsePreview ├── ResponsePreview.tsx ├── components │ └── FileItem │ └── FileItem.tsx └── index.ts
1 parent 8099a10 commit d4535a1

4 files changed

Lines changed: 106 additions & 5 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,19 @@ export const Prompt = () => {
671671
<UiResponsePreview
672672
items={items_in_preview}
673673
raw_instructions={raw_instructions}
674+
translations={{
675+
failed_to_apply_changes_to_file: t(
676+
'response-preview.failed-to-apply-changes-to-file'
677+
),
678+
files_failed_to_apply_changes: t(
679+
'response-preview.files-failed-to-apply-changes'
680+
),
681+
files_applied_with_fallback: t(
682+
'response-preview.files-applied-with-fallback'
683+
),
684+
fix: t('response-preview.fix'),
685+
fix_all: t('response-preview.fix-all')
686+
}}
674687
api_configuration_details={api_configuration_details}
675688
cli_configuration_details={cli_configuration_details}
676689
web_configuration_details={web_configuration_details}

‎apps/editor/src/views/prompt/frontend/i18n/translations/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { selected_files } from './selected-files'
99

1010
import { footer } from './footer'
1111
import { modals } from './modals'
12+
import { response_preview } from './response-preview'
1213

1314
export const translations = {
1415
...header,
@@ -20,5 +21,6 @@ export const translations = {
2021
...footer,
2122
...modals,
2223
...main,
23-
...selected_files
24+
...selected_files,
25+
...response_preview
2426
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export const response_preview = {
2+
'response-preview.failed-to-apply-changes-to-file': {
3+
en: 'Failed to apply changes to the file',
4+
pl: 'Nie udało się zastosować zmian w pliku',
5+
zh: '无法将更改应用到文件',
6+
es: 'No se pudieron aplicar los cambios al archivo',
7+
de: 'Änderungen konnten nicht auf die Datei angewendet werden',
8+
fr: 'Échec de l’application des modifications au fichier',
9+
ja: 'ファイルに変更を適用できませんでした',
10+
ko: '파일에 변경 사항을 적용하지 못했습니다',
11+
pt: 'Falha ao aplicar alterações ao arquivo',
12+
ru: 'Не удалось применить изменения к файлу',
13+
it: 'Impossibile applicare le modifiche al file',
14+
tr: 'Değişiklikler dosyaya uygulanamadı'
15+
},
16+
'response-preview.files-failed-to-apply-changes': {
17+
en: '{error_count} of {total_count} files failed to apply changes',
18+
pl: 'Nie udało się zastosować zmian w {error_count} z {total_count} plików',
19+
zh: '{total_count} 个文件中有 {error_count} 个无法应用更改',
20+
es: 'No se pudieron aplicar los cambios a {error_count} de {total_count} archivos',
21+
de: 'Bei {error_count} von {total_count} Dateien konnten Änderungen nicht angewendet werden',
22+
fr: 'Échec de l’application des modifications sur {error_count} fichiers sur {total_count}',
23+
ja: '{total_count} 個中 {error_count} 個のファイルに変更を適用できませんでした',
24+
ko: '{total_count}개 파일 중 {error_count}개에 변경 사항을 적용하지 못했습니다',
25+
pt: 'Falha ao aplicar alterações em {error_count} de {total_count} arquivos',
26+
ru: 'Не удалось применить изменения в {error_count} из {total_count} файлов',
27+
it: 'Impossibile applicare le modifiche a {error_count} di {total_count} file',
28+
tr: '{total_count} dosyadan {error_count} tanesine değişiklikler uygulanamadı'
29+
},
30+
'response-preview.files-applied-with-fallback': {
31+
en: '{count} of {total_count} files applied with fallback method',
32+
pl: 'Zastosowano metodą awaryjną w {count} z {total_count} plików',
33+
zh: '{total_count} 个文件中有 {count} 个使用了备用方法应用',
34+
es: '{count} de {total_count} archivos aplicados con método alternativo',
35+
de: '{count} von {total_count} Dateien mit Fallback-Methode angewendet',
36+
fr: '{count} fichiers sur {total_count} appliqués avec la méthode de secours',
37+
ja: '{total_count} 個中 {count} 個のファイルがフォールバック方式で適用されました',
38+
ko: '{total_count}개 파일 중 {count}개가 대체 방식으로 적용되었습니다',
39+
pt: '{count} de {total_count} arquivos aplicados com método alternativo',
40+
ru: '{count} из {total_count} файлов применено резервным методом',
41+
it: '{count} di {total_count} file applicati con metodo alternativo',
42+
tr: '{total_count} dosyadan {count} tanesi yedek yöntemle uygulandı'
43+
},
44+
'response-preview.fix': {
45+
en: 'Fix',
46+
pl: 'Napraw',
47+
zh: '修复',
48+
es: 'Corregir',
49+
de: 'Beheben',
50+
fr: 'Corriger',
51+
ja: '修正',
52+
ko: '수정',
53+
pt: 'Corrigir',
54+
ru: 'Исправить',
55+
it: 'Correggi',
56+
tr: 'Düzelt'
57+
},
58+
'response-preview.fix-all': {
59+
en: 'Fix all',
60+
pl: 'Napraw wszystkie',
61+
zh: '全部修复',
62+
es: 'Corregir todo',
63+
de: 'Alle beheben',
64+
fr: 'Tout corriger',
65+
ja: 'すべて修正',
66+
ko: '모두 수정',
67+
pt: 'Corrigir tudo',
68+
ru: 'Исправить все',
69+
it: 'Correggi tutto',
70+
tr: 'Tümünü düzelt'
71+
}
72+
} as const

‎packages/ui/src/components/editor/prompt-view/ResponsePreview/ResponsePreview.tsx‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ type Props = {
4949
cli_configuration_details?: CliConfigurationDetails
5050
web_configuration_details?: WebConfigurationDetails
5151
is_from_agentic_cli?: boolean
52+
translations: {
53+
failed_to_apply_changes_to_file: string
54+
files_failed_to_apply_changes: string
55+
files_applied_with_fallback: string
56+
fix: string
57+
fix_all: string
58+
}
5259
}
5360

5461
export const ResponsePreview: FC<Props> = (props) => {
@@ -295,16 +302,21 @@ export const ResponsePreview: FC<Props> = (props) => {
295302
icon="codicon-error"
296303
label={
297304
files_in_preview.length > 1
298-
? `${error_count} of ${files_in_preview.length} files failed to apply changes`
299-
: 'Failed to apply changes to the file'
305+
? props.translations.files_failed_to_apply_changes
306+
.replace('{error_count}', String(error_count))
307+
.replace('{total_count}', String(files_in_preview.length))
308+
: props.translations.failed_to_apply_changes_to_file
300309
}
301310
actions={
302311
!props.is_from_agentic_cli
303312
? [
304313
{
305314
id: 'fix',
306315
icon: 'codicon-sparkle',
307-
label: error_count > 1 ? 'Fix all' : 'Fix',
316+
label:
317+
error_count > 1
318+
? props.translations.fix_all
319+
: props.translations.fix,
308320
on_click: () => {
309321
set_is_fixing_all(true)
310322
const files_to_fix = files_in_preview
@@ -333,7 +345,9 @@ export const ResponsePreview: FC<Props> = (props) => {
333345
<StatusBar
334346
theme="warning"
335347
icon="codicon-warning"
336-
label={`${aggressive_fallback_count} of ${files_in_preview.length} files applied with fallback method`}
348+
label={props.translations.files_applied_with_fallback
349+
.replace('{count}', String(aggressive_fallback_count))
350+
.replace('{total_count}', String(files_in_preview.length))}
337351
/>
338352
</div>
339353
)}

0 commit comments

Comments
 (0)