Skip to content

Commit c5af013

Browse files
committed
Add strings to internationalization
1 parent 071ef49 commit c5af013

File tree

4 files changed

+62
-20
lines changed

4 files changed

+62
-20
lines changed

src/i18n/locales/en/translation.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
"NO_PROJECTS_FOUND": "No projects found",
5151
"CREATE_PROJECT_TO_START": "Please create a new project to get started.",
5252
"PAGINATION_ITEMS": "{range0}-{range1} of {total} items",
53+
"FAILED_TO_RENAME_MODULE": "Failed to rename module",
54+
"FAILED_TO_COPY_MODULE": "Failed to copy module",
55+
"MODULE_NOT_FOUND_FOR_COPYING": "Original module not found for copying",
56+
"COPY_SUFFIX": "{{name}} (copy)",
57+
"DELETE_MODULE_CONFIRM": "Delete {title}?",
58+
"MANAGEMENT": "Management",
59+
"TYPE_MANAGEMENT": "{{type}} Management",
60+
"RENAME_TYPE_TITLE": "Rename {{type}}: {{title}}",
61+
"COPY_TYPE_TITLE": "Copy {{type}}: {{title}}",
62+
"RENAME": "Rename",
63+
"NO_FILES_FOUND": "No {type} files found",
5364
"MECHANISMS": "Mechanisms",
5465
"OPMODES": "OpModes",
5566
"BLOCKLY":{
@@ -96,7 +107,8 @@
96107
"EVENTS": "Events",
97108
"ADD_MECHANISM": "+ Mechanism",
98109
"ADD_COMPONENT": "+ Component",
99-
"TEST": "Test"
110+
"TEST": "Test",
111+
"PAGINATION_TOTAL": "{{start}}-{{end}} of {{total}} items"
100112
}
101113
}
102114
}

src/i18n/locales/es/translation.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@
4747
"NO_PROJECTS_FOUND": "No se encontraron proyectos",
4848
"CREATE_PROJECT_TO_START": "Por favor crea un nuevo proyecto para comenzar.",
4949
"PAGINATION_ITEMS": "{range0}-{range1} de {total} elementos",
50+
"FAILED_TO_RENAME_MODULE": "Error al renombrar módulo",
51+
"FAILED_TO_COPY_MODULE": "Error al copiar módulo",
52+
"MODULE_NOT_FOUND_FOR_COPYING": "Módulo original no encontrado para copiar",
53+
"COPY_SUFFIX": "{{name}} (copia)",
54+
"DELETE_MODULE_CONFIRM": "¿Eliminar {title}?",
55+
"MANAGEMENT": "Gestión",
56+
"TYPE_MANAGEMENT": "Gestión de {{type}}",
57+
"RENAME_TYPE_TITLE": "Renombrar {{type}}: {{title}}",
58+
"COPY_TYPE_TITLE": "Copiar {{type}}: {{title}}",
59+
"RENAME": "Renombrar",
60+
"NO_FILES_FOUND": "No se encontraron archivos de {type}",
5061
"addTabDialog": {
5162
"title": "Agregar Pestaña",
5263
"search": "Buscar..."
@@ -97,7 +108,8 @@
97108
"EVENTS": "Eventos",
98109
"ADD_MECHANISM": "+ Mecanismo",
99110
"ADD_COMPONENT": "+ Componente",
100-
"TEST": "Prueba"
111+
"TEST": "Prueba",
112+
"PAGINATION_TOTAL": "{{start}}-{{end}} de {{total}} elementos"
101113
}
102114
}
103115
}

src/i18n/locales/he/translation.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
"NO_PROJECTS_FOUND": "לא נמצאו פרויקטים",
5151
"CREATE_PROJECT_TO_START": "אנא צור פרויקט חדש כדי להתחיל.",
5252
"PAGINATION_ITEMS": "{range0}-{range1} מתוך {total} פריטים",
53+
"FAILED_TO_RENAME_MODULE": "נכשל בשינוי שם המודול",
54+
"FAILED_TO_COPY_MODULE": "נכשל בהעתקת המודול",
55+
"MODULE_NOT_FOUND_FOR_COPYING": "המודול המקורי לא נמצא להעתקה",
56+
"COPY_SUFFIX": "{{name}} (עותק)",
57+
"DELETE_MODULE_CONFIRM": "מחק את {title}?",
58+
"MANAGEMENT": "ניהול",
59+
"TYPE_MANAGEMENT": "ניהול {{type}}",
60+
"RENAME_TYPE_TITLE": "שינוי שם {{type}}: {{title}}",
61+
"COPY_TYPE_TITLE": "העתקת {{type}}: {{title}}",
62+
"RENAME": "שנה שם",
63+
"NO_FILES_FOUND": "לא נמצאו קבצי {type}",
5364
"MECHANISMS": "מנגנונים",
5465
"OPMODES": "מצבי פעולה",
5566
"BLOCKLY":{
@@ -96,7 +107,8 @@
96107
"EVENTS": "אירועים",
97108
"ADD_MECHANISM": "+ מנגנון",
98109
"ADD_COMPONENT": "+ רכיב",
99-
"TEST": "בדיקה"
110+
"TEST": "בדיקה",
111+
"PAGINATION_TOTAL": "{{start}}-{{end}} מתוך {{total}} פריטים"
100112
}
101113
}
102114
}

src/reactComponents/FileManageModal.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default function FileManageModal(props: FileManageModalProps) {
127127
triggerProjectUpdate();
128128
} catch (error) {
129129
console.error('Error renaming module:', error);
130-
props.setAlertErrorMessage('Failed to rename module');
130+
props.setAlertErrorMessage(t('FAILED_TO_RENAME_MODULE'));
131131
}
132132

133133
setRenameModalOpen(false);
@@ -150,7 +150,7 @@ export default function FileManageModal(props: FileManageModalProps) {
150150
const originalModule = modules.find((module) => module.path === origModule.path);
151151
if (!originalModule) {
152152
console.error('Original module not found for copying:', origModule.path);
153-
props.setAlertErrorMessage('Original module not found for copying');
153+
props.setAlertErrorMessage(t('MODULE_NOT_FOUND_FOR_COPYING'));
154154
return;
155155
}
156156

@@ -165,7 +165,7 @@ export default function FileManageModal(props: FileManageModalProps) {
165165
triggerProjectUpdate();
166166
} catch (error) {
167167
console.error('Error copying module:', error);
168-
props.setAlertErrorMessage('Failed to copy module');
168+
props.setAlertErrorMessage(t('FAILED_TO_COPY_MODULE'));
169169
}
170170

171171
setCopyModalOpen(false);
@@ -243,14 +243,14 @@ export default function FileManageModal(props: FileManageModalProps) {
243243
/** Opens the copy modal for a specific module. */
244244
const openCopyModal = (record: Module): void => {
245245
setCurrentRecord(record);
246-
setName(record.title + 'Copy');
246+
setName(t('COPY_SUFFIX', { name: record.title }));
247247
setCopyModalOpen(true);
248248
};
249249

250250
/** Table column configuration. */
251251
const columns: Antd.TableProps<Module>['columns'] = [
252252
{
253-
title: 'Name',
253+
title: t('NAME'),
254254
dataIndex: 'title',
255255
key: 'title',
256256
ellipsis: {
@@ -263,12 +263,12 @@ export default function FileManageModal(props: FileManageModalProps) {
263263
),
264264
},
265265
{
266-
title: 'Actions',
266+
title: t('ACTIONS'),
267267
key: 'actions',
268268
width: ACTIONS_COLUMN_WIDTH,
269269
render: (_, record: Module) => (
270270
<Antd.Space size="small">
271-
<Antd.Tooltip title={t('Rename')}>
271+
<Antd.Tooltip title={t('RENAME')}>
272272
<Antd.Button
273273
type="text"
274274
size="small"
@@ -279,7 +279,7 @@ export default function FileManageModal(props: FileManageModalProps) {
279279
}}
280280
/>
281281
</Antd.Tooltip>
282-
<Antd.Tooltip title={t('Copy')}>
282+
<Antd.Tooltip title={t('COPY')}>
283283
<Antd.Button
284284
type="text"
285285
size="small"
@@ -292,8 +292,8 @@ export default function FileManageModal(props: FileManageModalProps) {
292292
</Antd.Tooltip>
293293
<Antd.Tooltip title={t('Delete')}>
294294
<Antd.Popconfirm
295-
title={`Delete ${record.title}?`}
296-
description="This action cannot be undone."
295+
title={t('DELETE_MODULE_CONFIRM', { title: record.title })}
296+
description={t('DELETE_CANNOT_BE_UNDONE')}
297297
onConfirm={() => handleDeleteConfirm(record)}
298298
okText={t('Delete')}
299299
cancelText={t('Cancel')}
@@ -315,29 +315,35 @@ export default function FileManageModal(props: FileManageModalProps) {
315315

316316
/** Gets the modal title based on module type. */
317317
const getModalTitle = (): string => {
318-
return `${TabTypeUtils.toString(props.tabType)} Management`;
318+
return t('TYPE_MANAGEMENT', { type: TabTypeUtils.toString(props.tabType) });
319319
};
320320

321321
/** Gets the rename modal title. */
322322
const getRenameModalTitle = (): string => {
323323
if (!currentRecord) {
324-
return 'Rename';
324+
return t('RENAME');
325325
}
326-
return `Rename ${TabTypeUtils.toString(currentRecord.type)}: ${currentRecord.title}`;
326+
return t('RENAME_TYPE_TITLE', {
327+
type: TabTypeUtils.toString(currentRecord.type),
328+
title: currentRecord.title
329+
});
327330
};
328331

329332
/** Gets the copy modal title. */
330333
const getCopyModalTitle = (): string => {
331334
if (!currentRecord) {
332-
return 'Copy';
335+
return t('COPY');
333336
}
334-
return `Copy ${TabTypeUtils.toString(currentRecord.type)}: ${currentRecord.title}`;
337+
return t('COPY_TYPE_TITLE', {
338+
type: TabTypeUtils.toString(currentRecord.type),
339+
title: currentRecord.title
340+
});
335341
};
336342

337343
/** Gets the empty table text based on tab type. */
338344
const getEmptyText = (): string => {
339345
const tabTypeString = TabTypeUtils.toString(props.tabType || TabType.OPMODE);
340-
return `No ${tabTypeString.toLowerCase()} files found`;
346+
return t('NO_FILES_FOUND', { type: tabTypeString.toLowerCase() });
341347
};
342348

343349
return (
@@ -417,7 +423,7 @@ export default function FileManageModal(props: FileManageModalProps) {
417423
showSizeChanger: false,
418424
showQuickJumper: false,
419425
showTotal: (total, range) =>
420-
`${range[0]}-${range[1]} of ${total} items`,
426+
t('PAGINATION_TOTAL', { start: range[0], end: range[1], total }),
421427
} : false}
422428
bordered
423429
locale={{

0 commit comments

Comments
 (0)