Skip to content

Commit d1319a2

Browse files
committed
Add internationalization support to the responses component
- when no instructions, instead of 'response preview', show em dash - translate 'applied manually', use translations:{} prop ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Home │ │ └── Home.tsx │ ├── Main │ │ └── MainView │ │ └── MainView.tsx │ └── i18n │ └── translations │ ├── actions.ts │ ├── common.ts │ ├── configurations.ts │ ├── footer.ts │ ├── header.ts │ ├── home.ts │ ├── index.ts │ ├── main.ts │ ├── modals.ts │ ├── prompt-field.ts │ ├── recent-donations.ts │ └── selected-files.ts └── packages └── ui └── src └── components └── editor └── prompt └── Responses ├── Responses.module.scss ├── Responses.stories.tsx └── Responses.tsx
1 parent 2557bcb commit d1319a2

6 files changed

Lines changed: 54 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ export const Home: React.FC<Props> = (props) => {
217217
on_response_history_item_remove={
218218
props.on_response_history_item_remove
219219
}
220+
translations={{
221+
applied_manually: t('common.applied-manually'),
222+
reject: t('action.reject')
223+
}}
220224
/>
221225
</div>
222226
)}

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ export const MainView: React.FC<Props> = (props) => {
278278
on_response_history_item_remove={
279279
props.on_response_history_item_remove
280280
}
281+
translations={{
282+
applied_manually: t('common.applied-manually'),
283+
reject: t('action.reject')
284+
}}
281285
/>
282286
)}
283287

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,23 @@ export const actions = {
160160
cs: 'Použít',
161161
hu: 'Alkalmaz',
162162
bg: 'Приложи'
163+
},
164+
'action.reject': {
165+
en: 'Reject',
166+
pl: 'Odrzuć',
167+
'zh-cn': '拒绝',
168+
ja: '拒否',
169+
'zh-tw': '拒絕',
170+
de: 'Ablehnen',
171+
es: 'Rechazar',
172+
fr: 'Rejeter',
173+
'pt-br': 'Rejeitar',
174+
ru: 'Отклонить',
175+
ko: '거부',
176+
it: 'Rifiuta',
177+
tr: 'Reddet',
178+
cs: 'Odmítnout',
179+
hu: 'Elutasít',
180+
bg: 'Отхвърляне'
163181
}
164182
} as const

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,23 @@ export const common = {
3434
cs: 'Kontext je prázdný',
3535
hu: 'A kontextus üres',
3636
bg: 'Контекстът е празен'
37+
},
38+
'common.applied-manually': {
39+
en: 'Applied manually',
40+
pl: 'Zastosowano ręcznie',
41+
'zh-cn': '手动应用',
42+
ja: '手動で適用',
43+
'zh-tw': '手動應用',
44+
de: 'Manuell angewendet',
45+
es: 'Aplicado manualmente',
46+
fr: 'Appliqué manuellement',
47+
'pt-br': 'Aplicado manualmente',
48+
ru: 'Применено вручную',
49+
ko: '수동으로 적용됨',
50+
it: 'Applicato manualmente',
51+
tr: 'Manuel olarak uygulandı',
52+
cs: 'Ručně aplikováno',
53+
hu: 'Manuálisan alkalmazva',
54+
bg: 'Приложено ръчно'
3755
}
3856
} as const

‎packages/ui/src/components/editor/prompt/Responses/Responses.stories.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export const Primary = () => {
4747
on_response_history_item_remove={(created_at) => {
4848
console.log('remove item', created_at)
4949
}}
50+
translations={{
51+
applied_manually: 'Applied manually',
52+
reject: 'Reject'
53+
}}
5054
/>
5155
)
5256
}

‎packages/ui/src/components/editor/prompt/Responses/Responses.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ type Props = {
1515
on_response_history_item_remove: (created_at: number) => void
1616
selected_history_item_created_at?: number
1717
on_selected_history_item_change: (created_at: number) => void
18+
translations?: {
19+
applied_manually: string
20+
reject: string
21+
}
1822
}
1923

2024
export const Responses: React.FC<Props> = (props) => {
@@ -72,7 +76,7 @@ export const Responses: React.FC<Props> = (props) => {
7276
]
7377
}
7478
>
75-
Response preview
79+
{props.translations?.applied_manually || 'Applied manually'}
7680
</span>
7781
)}
7882
</div>
@@ -111,7 +115,7 @@ export const Responses: React.FC<Props> = (props) => {
111115
onClick={() => {
112116
props.on_response_history_item_remove(item.created_at)
113117
}}
114-
title="Reject"
118+
title={props.translations?.reject || 'Reject'}
115119
>
116120
<span className="codicon codicon-close-small" />
117121
</button>

0 commit comments

Comments
 (0)