Skip to content

Commit 27cac1f

Browse files
committed
Add i18n support for Tabs
1 parent 03cc65c commit 27cac1f

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

src/i18n/locales/en/translation.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"COPY_TYPE_TITLE": "Copy {{type}}: {{title}}",
7070
"RENAME": "Rename",
7171
"NO_FILES_FOUND": "No {{type}} files found",
72+
"DELETE": "Delete",
73+
"CANCEL": "Cancel",
74+
"CLOSE_TAB": "Close Tab",
75+
"CLOSE_OTHER_TABS": "Close Other tabs",
76+
"RENAME_ELLIPSIS": "Rename...",
77+
"DELETE_ELLIPSIS": "Delete...",
78+
"COPY_ELLIPSIS": "Copy...",
7279
"MECHANISMS": "Mechanisms",
7380
"OPMODES": "OpModes",
7481
"BLOCKLY":{

src/i18n/locales/es/translation.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
"COPY_TYPE_TITLE": "Copiar {{type}}: {{title}}",
6767
"RENAME": "Renombrar",
6868
"NO_FILES_FOUND": "No se encontraron archivos de {{type}}",
69+
"DELETE": "Eliminar",
70+
"CANCEL": "Cancelar",
71+
"CLOSE_TAB": "Cerrar Pestaña",
72+
"CLOSE_OTHER_TABS": "Cerrar Otras Pestañas",
73+
"RENAME_ELLIPSIS": "Renombrar...",
74+
"DELETE_ELLIPSIS": "Eliminar...",
75+
"COPY_ELLIPSIS": "Copiar...",
6976
"addTabDialog": {
7077
"title": "Agregar Pestaña",
7178
"search": "Buscar..."

src/i18n/locales/he/translation.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"COPY_TYPE_TITLE": "העתקת {{type}}: {{title}}",
7070
"RENAME": "שנה שם",
7171
"NO_FILES_FOUND": "לא נמצאו קבצי {{type}}",
72+
"DELETE": "מחק",
73+
"CANCEL": "בטל",
74+
"CLOSE_TAB": "סגור לשונית",
75+
"CLOSE_OTHER_TABS": "סגור לשוניות אחרות",
76+
"RENAME_ELLIPSIS": "שנה שם...",
77+
"DELETE_ELLIPSIS": "מחק...",
78+
"COPY_ELLIPSIS": "העתק...",
7279
"MECHANISMS": "מנגנונים",
7380
"OPMODES": "אופמודים",
7481
"BLOCKLY": {

src/reactComponents/Tabs.tsx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface TabsProps {
5656
}
5757

5858
/** Default copy suffix for tab names. */
59-
const COPY_SUFFIX = 'Copy';
59+
const COPY_SUFFIX = ' (copy)';
6060

6161
/** Minimum number of tabs required to show close others option. */
6262
const MIN_TABS_FOR_CLOSE_OTHERS = 2;
@@ -186,7 +186,7 @@ export function Component(props: TabsProps): React.JSX.Element {
186186
triggerProjectUpdate();
187187
} catch (error) {
188188
console.error('Error renaming module:', error);
189-
props.setAlertErrorMessage('Failed to rename module');
189+
props.setAlertErrorMessage(t('FAILED_TO_RENAME_MODULE'));
190190
}
191191

192192
setRenameModalOpen(false);
@@ -213,7 +213,7 @@ export function Component(props: TabsProps): React.JSX.Element {
213213

214214
if (!originalTab) {
215215
console.error('Original tab not found for copying:', key);
216-
props.setAlertErrorMessage('Original tab not found for copying');
216+
props.setAlertErrorMessage(t('MODULE_NOT_FOUND_FOR_COPYING'));
217217
return;
218218
}
219219

@@ -223,7 +223,7 @@ export function Component(props: TabsProps): React.JSX.Element {
223223
triggerProjectUpdate();
224224
} catch (error) {
225225
console.error('Error copying module:', error);
226-
props.setAlertErrorMessage('Failed to copy module');
226+
props.setAlertErrorMessage(t('FAILED_TO_COPY_MODULE'));
227227
}
228228

229229
setCopyModalOpen(false);
@@ -260,11 +260,11 @@ export function Component(props: TabsProps): React.JSX.Element {
260260
const titleToShow = currentTab ? currentTab.title : tab.title;
261261

262262
modal.confirm({
263-
title: `${t('Delete')} ${TabTypeUtils.toString(tab.type)}: ${titleToShow}`,
264-
content: t('Are you sure you want to delete this? This action cannot be undone.'),
265-
okText: t('Delete'),
263+
title: t('DELETE_MODULE_CONFIRM', { title: `${TabTypeUtils.toString(tab.type)}: ${titleToShow}` }),
264+
content: t('DELETE_CANNOT_BE_UNDONE'),
265+
okText: t('DELETE'),
266266
okType: 'danger',
267-
cancelText: t('Cancel'),
267+
cancelText: t('CANCEL'),
268268
onOk: async (): Promise<void> => {
269269
const newTabs = props.tabList.filter((t) => t.key !== tab.key);
270270
props.setTabList(newTabs);
@@ -290,35 +290,35 @@ export function Component(props: TabsProps): React.JSX.Element {
290290
const createTabContextMenuItems = (tab: TabItem): any[] => [
291291
{
292292
key: 'close',
293-
label: t('Close Tab'),
293+
label: t('CLOSE_TAB'),
294294
onClick: () => handleTabEdit(tab.key, 'remove'),
295295
disabled: tab.type === TabType.ROBOT,
296296
icon: <CloseOutlined />,
297297
},
298298
{
299299
key: 'close-others',
300-
label: t('Close Other tabs'),
300+
label: t('CLOSE_OTHER_TABS'),
301301
onClick: () => handleCloseOtherTabs(tab.key),
302302
disabled: props.tabList.length <= getMinTabsForCloseOthers(tab.type),
303303
icon: <CloseCircleOutlined />,
304304
},
305305
{
306306
key: 'rename',
307-
label: t('Rename...'),
307+
label: t('RENAME_ELLIPSIS'),
308308
disabled: tab.type === TabType.ROBOT,
309309
onClick: () => handleOpenRenameModal(tab),
310310
icon: <EditOutlined />,
311311
},
312312
{
313313
key: 'delete',
314-
label: t('Delete...'),
314+
label: t('DELETE_ELLIPSIS'),
315315
disabled: tab.type === TabType.ROBOT,
316316
icon: <DeleteOutlined />,
317317
onClick: () => handleDeleteTab(tab),
318318
},
319319
{
320320
key: 'copy',
321-
label: t('Copy...'),
321+
label: t('COPY_ELLIPSIS'),
322322
disabled: tab.type === TabType.ROBOT,
323323
icon: <CopyOutlined />,
324324
onClick: () => handleOpenCopyModal(tab),
@@ -366,17 +366,16 @@ export function Component(props: TabsProps): React.JSX.Element {
366366
/>
367367

368368
<Antd.Modal
369-
title={`Rename ${currentTab ? TabTypeUtils.toString(currentTab.type) : ''}: ${currentTab ? currentTab.title : ''
370-
}`}
369+
title={t('RENAME_TYPE_TITLE', { type: currentTab ? TabTypeUtils.toString(currentTab.type) : '', title: currentTab ? currentTab.title : '' })}
371370
open={renameModalOpen}
372371
onCancel={() => setRenameModalOpen(false)}
373372
onOk={() => {
374373
if (currentTab) {
375374
handleRename(currentTab.key, name);
376375
}
377376
}}
378-
okText={t('Rename')}
379-
cancelText={t('Cancel')}
377+
okText={t('RENAME')}
378+
cancelText={t('CANCEL')}
380379
>
381380
{currentTab && (
382381
<ClassNameComponent
@@ -396,17 +395,16 @@ export function Component(props: TabsProps): React.JSX.Element {
396395
</Antd.Modal>
397396

398397
<Antd.Modal
399-
title={`Copy ${currentTab ? TabTypeUtils.toString(currentTab.type) : ''}: ${currentTab ? currentTab.title : ''
400-
}`}
398+
title={t('COPY_TYPE_TITLE', { type: currentTab ? TabTypeUtils.toString(currentTab.type) : '', title: currentTab ? currentTab.title : '' })}
401399
open={copyModalOpen}
402400
onCancel={() => setCopyModalOpen(false)}
403401
onOk={() => {
404402
if (currentTab) {
405403
handleCopy(currentTab.key, name);
406404
}
407405
}}
408-
okText={t('Copy')}
409-
cancelText={t('Cancel')}
406+
okText={t('COPY')}
407+
cancelText={t('CANCEL')}
410408
>
411409
{currentTab && (
412410
<ClassNameComponent

0 commit comments

Comments
 (0)