Skip to content

Commit

Permalink
Merge pull request #616 from kbss-cvut/fix/568-fix-localization
Browse files Browse the repository at this point in the history
Fix localization
  • Loading branch information
blcham authored Oct 2, 2024
2 parents 81508f0 + 68b6a29 commit da9881a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 34 deletions.
17 changes: 16 additions & 1 deletion public/locales/cs/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"user": {
"logout": "Odhlásit se",
"changePassword": "Změnit heslo"
},
"categories": {
"systems": "Systémy",
"trees": "Poruchové stromy",
Expand Down Expand Up @@ -30,6 +34,10 @@
"gateType": "Typ hradla",
"noSystemError": "Na panelu Navigační panel vyberte možnost Systém"
},
"deleteFtaModal": {
"title": "Smazat strom poruch",
"explanation": "Smazáním stromu chyb se smaže celá stromová struktura. Pokračovat ve smazání stromu?"
},
"newFmeaModal": {
"title": "FMEA agregáty",
"namePlaceholder": "Název FMEA",
Expand All @@ -38,7 +46,8 @@
},
"diagramSidePanel": {
"cutsetToggleToolTip": "Přepnout do pohledu řezu",
"minimumOperationalHours": "Min. provozní doba"
"minimumOperationalHours": "Min. provozní doba",
"diagramOptions": "Možnosti diagramu"
},
"faultEventScenariosTable": {
"cutset": "Řez",
Expand Down Expand Up @@ -95,6 +104,12 @@
"created": "Vytvořeno",
"operationalHours": "Doba provozu"
},
"systemComponentMenu": {
"editComponent": "Upravit komponentu",
"notSelected": "Není vybrána žádná komponenta",
"functions": "Funkce",
"linkedComponent": "Propojená komponenta"
},
"faultEventMenu": {
"eventName": "Název události",
"criticality": "Kritičnost",
Expand Down
17 changes: 16 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"user": {
"logout": "Logout",
"changePassword": "Change password"
},
"categories": {
"systems": "Systems",
"trees": "Fault trees",
Expand Down Expand Up @@ -30,6 +34,10 @@
"gateType": "Gate type",
"noSystemError": "Select the System from the Navbar"
},
"deleteFtaModal": {
"title": "Delete Fault Tree",
"explanation": "Deleting fault tree will delete the whole tree structure. Proceed to delete the tree?"
},
"newFmeaModal": {
"title": "FMEA Aggregates",
"namePlaceholder": "FMEA Name",
Expand All @@ -38,7 +46,8 @@
},
"diagramSidePanel": {
"cutsetToggleToolTip": "Switch to cutsets view",
"minimumOperationalHours": "Min. operational hours"
"minimumOperationalHours": "Min. operational hours",
"diagramOptions": "Diagram Options"
},
"faultEventScenariosTable": {
"cutset": "Cutset",
Expand Down Expand Up @@ -95,6 +104,12 @@
"created": "Created",
"operationalHours": "Operational Hours"
},
"systemComponentMenu": {
"editComponent": "Edit Component",
"notSelected": "No component selected",
"functions": "Functions",
"linkedComponent": "Linked Component"
},
"faultEventMenu": {
"eventName": "Event name",
"criticality": "Criticality",
Expand Down
4 changes: 2 additions & 2 deletions src/components/appBar/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
{loggedUser.roles && loggedUser.roles.indexOf("ROLE_ADMIN") >= 0 && (
<MenuItem onClick={navigateToAdmin}>Administration</MenuItem>
)}
{!isUsingOidcAuth() && <MenuItem onClick={handleChangePasswordDialogOpen}>Change Password</MenuItem>}
{!isUsingOidcAuth() && <MenuItem onClick={handleChangePasswordDialogOpen}>{t("user.changePassword")}</MenuItem>}

<MenuItem onClick={handleLogout}>Logout</MenuItem>
<MenuItem onClick={handleLogout}>{t("user.logout")}</MenuItem>
</Menu>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import { Link as RouterLink } from "react-router-dom";
import { extractFragment } from "@services/utils/uriIdentifierUtils";
import { ROUTES } from "@utils/constants";
import { contextMenuDefaultAnchor, ElementContextMenuAnchor } from "@utils/contextMenu";
import { useTranslation } from "react-i18next";

const DashboardFaultTreeList = () => {
const { classes } = useStyles();
const { t } = useTranslation();

const [faultTrees, , , removeTree] = useFaultTrees();

const [contextMenuSelectedTree, setContextMenuSelectedTree] = useState<FaultTree>(null);
Expand All @@ -39,9 +42,8 @@ const DashboardFaultTreeList = () => {

const handleDelete = (treeToDelete: FaultTree) => {
showConfirmDialog({
title: "Delete Fault Tree",
explanation:
"Deleting fault tree will delete the whole tree structure. Events will remain. Proceed to delete the tree?",
title: t("deleteFtaModal.title"),
explanation: t("deleteFtaModal.explanation"),
onConfirm: () => {
removeTree(treeToDelete);
},
Expand Down
5 changes: 2 additions & 3 deletions src/components/dashboard/content/list/FaultTreeOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ const FaultTreeOverview = () => {

const handleDelete = (treeToDelete: FaultTree) => {
showConfirmDialog({
title: "Delete Fault Tree",
explanation:
"Deleting fault tree will delete the whole tree structure. Events will remain. Proceed to delete the tree?",
title: t("deleteFtaModal.title"),
explanation: t("deleteFtaModal.explanation"),
onConfirm: () => {
removeTree(treeToDelete);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,6 @@ const FaultEventMenu = ({ selectedShapeToolData, onEventUpdated, refreshTree, ro

<EventFailureModeList onFailureModeClick={handleFailureModeClicked} />

<Button color="primary" onClick={() => setFailureModeDialogOpen(true)}>
Set Failure Mode
</Button>

<FailureModeDialog
open={failureModeDialogOpen && Boolean(shapeToolData)}
onClose={() => setFailureModeDialogOpen(false)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/menu/DiagramOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DiagramOptions = ({
return (
<React.Fragment>
<Typography variant="h5" gutterBottom>
Diagram Options
{t("diagramSidePanel.diagramOptions")}
</Typography>
<div>
<IconButton color="primary" onClick={onApplyAutomaticLayout} aria-label="restore layout" size="large">
Expand Down
6 changes: 4 additions & 2 deletions src/components/editor/system/menu/SystemContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from "react";
import { Menu, MenuItem } from "@mui/material";
import { ElementContextMenuAnchor } from "@utils/contextMenu";
import { useTranslation } from "react-i18next";

interface Props {
anchorPosition: ElementContextMenuAnchor;
Expand All @@ -10,6 +11,7 @@ interface Props {
}

const SystemContextMenu = ({ anchorPosition, onClose, onEditClick, onDelete }: Props) => {
const { t } = useTranslation();
const handleEditClick = () => {
onClose();
onEditClick();
Expand All @@ -36,10 +38,10 @@ const SystemContextMenu = ({ anchorPosition, onClose, onEditClick, onDelete }: P
}
>
<MenuItem key="system-menu-rename" onClick={handleEditClick}>
Rename
{t("common.rename")}
</MenuItem>
<MenuItem key="system-delete" onClick={handleDeleteClick}>
Delete
{t("common.delete")}
</MenuItem>
</Menu>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ControlledAutocomplete from "@components/materialui/ControlledAutocomplet
import { useForm } from "react-hook-form";
import { FailureModeProvider } from "@hooks/useFailureModes";
import { simplifyReferences } from "@utils/utils";
import { useTranslation } from "react-i18next";

interface Props {
component: Component;
Expand All @@ -22,6 +23,7 @@ interface Props {

const ComponentSidebarMenu = ({ component, onComponentUpdated, systemComponents }: Props) => {
const [showSnackbar] = useSnackbar();
const { t } = useTranslation();

const allowedComponents = filter(flatten([systemComponents]), (o) => o.iri !== component?.iri);

Expand Down Expand Up @@ -61,21 +63,21 @@ const ComponentSidebarMenu = ({ component, onComponentUpdated, systemComponents
return (
<React.Fragment>
<Typography variant="h5" gutterBottom>
Edit Component
{t("systemComponentMenu.editComponent")}
</Typography>
{component ? (
<ComponentEditMenu component={component} onComponentUpdated={onComponentUpdated} />
) : (
<Typography variant="subtitle1" gutterBottom>
No component selected
{t("systemComponentMenu.notSelected")}
</Typography>
)}
<Divider />

{component && (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Functions
{t("systemComponentMenu.functions")}
</Typography>
<FunctionsProvider componentUri={component?.iri}>
<FailureModeProvider component={component}>
Expand All @@ -90,7 +92,7 @@ const ComponentSidebarMenu = ({ component, onComponentUpdated, systemComponents
{component && (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Linked Component
{t("systemComponentMenu.linkedComponent")}
</Typography>
<ControlledAutocomplete
control={control}
Expand Down
7 changes: 4 additions & 3 deletions src/components/materialui/FaultTreeListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { FaultTree } from "@models/faultTreeModel";
import { useConfirmDialog } from "@hooks/useConfirmDialog";
import { useFaultTrees } from "@hooks/useFaultTrees";
import FaultTreeEditDialog from "@components/dialog/faultTree/FaultTreeEditDialog";
import { useTranslation } from "react-i18next";

interface Props {
faultTree: FaultTree;
onClick: (any) => void;
}

const FaultTreeListItem = ({ faultTree, onClick }: Props) => {
const { t } = useTranslation();
const [contextMenuSelectedTree, setContextMenuSelectedTree] = useState<FaultTree>(null);
const [contextMenuAnchor, setContextMenuAnchor] = useState<ElementContextMenuAnchor>(contextMenuDefaultAnchor);

Expand All @@ -32,9 +34,8 @@ const FaultTreeListItem = ({ faultTree, onClick }: Props) => {

const handleDelete = (treeToDelete: FaultTree) => {
showConfirmDialog({
title: "Delete Fault Tree",
explanation:
"Deleting fault tree will delete the whole tree structure. Events will remain. Proceed to delete the tree?",
title: t("deleteFtaModal.title"),
explanation: t("deleteFtaModal.explanation"),
onConfirm: () => {
removeTree(treeToDelete);
},
Expand Down
21 changes: 11 additions & 10 deletions src/components/table/FaultTreeTableHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC } from "react";
import { TableCell, TableRow, Box, TableSortLabel } from "@mui/material";
import FilterListIcon from "@mui/icons-material/FilterList";
import useStyles from "./FaultTreeOverviewTable.styles";
import { useTranslation } from "react-i18next";

interface FaultTreeTableHeadProps {
sortConfig: { key: string; direction: "asc" | "desc" };
Expand All @@ -12,13 +13,13 @@ interface FaultTreeTableHeadProps {

const FaultTreeTableHead: FC<FaultTreeTableHeadProps> = ({ sortConfig, onSortChange, onFilterClick, filterValues }) => {
const { classes } = useStyles();

const { t } = useTranslation();
return (
<TableRow>
<TableCell className={classes.tableHeaderCell}>
<Box display="flex" alignItems="center">
<span onClick={(e) => onFilterClick(e, "label")} style={{ cursor: "pointer", marginRight: "8px" }}>
FHA Label
{t("faultTreeOverviewTable.name")}
</span>
{filterValues.label && <FilterListIcon />}
<TableSortLabel
Expand All @@ -28,11 +29,11 @@ const FaultTreeTableHead: FC<FaultTreeTableHeadProps> = ({ sortConfig, onSortCha
/>
</Box>
</TableCell>
<TableCell className={classes.tableHeaderCell}>Aircraft Type</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.aircraftType")}</TableCell>
<TableCell className={classes.tableHeaderCell}>
<Box>
<span onClick={(e) => onFilterClick(e, "snsLabel")} style={{ cursor: "pointer" }}>
SNS Label
{t("faultTreeOverviewTable.sns")}
</span>
{filterValues.snsLabel && <FilterListIcon />}
<TableSortLabel
Expand All @@ -42,21 +43,21 @@ const FaultTreeTableHead: FC<FaultTreeTableHeadProps> = ({ sortConfig, onSortCha
/>
</Box>
</TableCell>
<TableCell className={classes.tableHeaderCell}>Calculated Failure Rate</TableCell>
<TableCell className={classes.tableHeaderCell}>FHA Based Failure Rate</TableCell>
<TableCell className={classes.tableHeaderCell}>Required Failure Rate</TableCell>
<TableCell className={classes.tableHeaderCell}>Last Modified</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.calculatedFailureRate")}</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.fhaBasedFailureRate")}</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.requiredFailureRate")}</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.lastModified")}</TableCell>
<TableCell className={classes.tableHeaderCell}>
<Box>
Created
{t("faultTreeOverviewTable.created")}
<TableSortLabel
active={sortConfig.key === "date"}
direction={sortConfig.key === "date" ? sortConfig.direction : "desc"}
onClick={() => onSortChange("date")}
/>
</Box>
</TableCell>
<TableCell className={classes.tableHeaderCell}>Last Editor</TableCell>
<TableCell className={classes.tableHeaderCell}>{t("faultTreeOverviewTable.lastEditor")}</TableCell>
</TableRow>
);
};
Expand Down

0 comments on commit da9881a

Please sign in to comment.