Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Annotator/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useEventCallback from "use-event-callback"
import videoReducer from "./reducers/video-reducer.js"
import PropTypes from "prop-types"
import noopReducer from "./reducers/noop-reducer.js"
import {useTranslation} from "react-i18next"


export const Annotator = ({
Expand Down Expand Up @@ -56,6 +57,7 @@ export const Annotator = ({
selectedImage = (images || []).findIndex((img) => img.src === selectedImage)
if (selectedImage === -1) selectedImage = undefined
}
const {t} = useTranslation();
const annotationType = images ? "image" : "video"
const [state, dispatchToReducer] = useReducer(
historyHandler(
Expand Down Expand Up @@ -130,9 +132,9 @@ export const Annotator = ({
image: state.images[selectedImage]
})
}, [selectedImage, state.images])

if (!images && !videoSrc)
return "Missing required prop \"images\" or \"videoSrc\""
return t("error.imagevideo")

return (
<SettingsProvider>
Expand Down
7 changes: 4 additions & 3 deletions src/Annotator/reducers/general-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import convertExpandingLineToPolygon from "./convert-expanding-line-to-polygon"
import clamp from "../../utils/clamp.js"
import getLandmarksWithTransform from "../../utils/get-landmarks-with-transform"
import setInLocalStorage from "../../utils/set-in-local-storage"
import i18next from "i18next"

const getRandomId = () => Math.random().toString().split(".")[1]

Expand Down Expand Up @@ -201,7 +202,7 @@ export default (state, action) => {
null
)
} else {
state = saveToHistory(state, "Move Polygon Point")
state = saveToHistory(state, i18next.t("move.polypoint"))
}
return setIn(state, ["mode"], {
mode: "MOVE_POLYGON_POINT",
Expand Down Expand Up @@ -579,7 +580,7 @@ export default (state, action) => {
}
case "create-polygon": {
if (state.mode && state.mode.mode === "DRAW_POLYGON") break
state = saveToHistory(state, "Create Polygon")
state = saveToHistory(state, i18next.t("create.polygon"))
newRegion = {
type: "polygon",
points: [
Expand Down Expand Up @@ -618,7 +619,7 @@ export default (state, action) => {
}
case "create-line": {
if (state.mode && state.mode.mode === "DRAW_LINE") break
state = saveToHistory(state, "Create Line")
state = saveToHistory(state, i18next.t("create.line"))
newRegion = {
type: "line",
x1: x,
Expand Down
7 changes: 0 additions & 7 deletions src/FullImageSegmentationAnnotator/index.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/HistorySidebarBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const HistorySidebarBox = ({
>
<List>
{history.length === 0 && (
<EmptyTextDiv>No History Yet</EmptyTextDiv>
<EmptyTextDiv>{t("no.history")}</EmptyTextDiv>
)}
{history.map(({name, time}, i) => (
<ListItem button dense key={i}>
Expand Down
9 changes: 8 additions & 1 deletion src/Localization/translation-de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ const translationDeDE = {
"menu.classifications": "Klassifizierungen",
"menu.history": "Verlauf",
"menu.regions": "Regionen",
"error.image": "Bild konnte nicht geladen werden."
"error.image": "Bild konnte nicht geladen werden.",
"error.imagevideo": "Fehler im Bild oder Video",
"no.history": "Kein Verlauf vorhanden",
"desc.class": "Klassen",
"move.polypoint": "Polygon Punkt verschoben",
"create.polygon": "Polygon erstellen",
"create.line": "Lichtschranke erstellen",
"region.label": "Bezeichnung"
};

export default translationDeDE;
9 changes: 8 additions & 1 deletion src/Localization/translation-en-EN.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ const translationEnEN = {
"menu.classifications": "Classifications",
"menu.history": "History",
"menu.regions": "Regions",
"error.image": "Could not load image"
"error.image": "Could not load image",
"error.imagevideo": "Missing required prop",
"no.history": "No History Yet",
"desc.class": "Class",
"move.polypoint": "Move Polygon Point",
"create.polygon": "Create Polygon",
"create.line": "Create Line",
"region.label": "Designation"
};

export default translationEnEN;
7 changes: 5 additions & 2 deletions src/RegionLabel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CheckIcon from "@mui/icons-material/Check"
import TextField from "@mui/material/TextField"
import Select from "react-select"
import CreatableSelect from "react-select/creatable"
import {useTranslation} from "react-i18next"

import {asMutable} from "seamless-immutable"

Expand All @@ -30,6 +31,7 @@ export const RegionLabel = ({
enabledProperties
}) => {
const commentInputRef = useRef(null)
const {t} = useTranslation();
const onCommentInputClick = (_) => {
// The TextField wraps the <input> tag with two divs
const commentInput = commentInputRef.current.children[0].children[0]
Expand Down Expand Up @@ -169,15 +171,16 @@ export const RegionLabel = ({
{enabledProperties.includes("name") && (
<TextField
id="nameField"
label="name"
label={t("region.label")}
ref={nameInputRef}
onClick={onNameInputClick}
value={region.name || ""}
onChange={(event) =>
onChange({...(region), name: event.target.value})
}
/>
)}
)
}
{onClose && (
<div style={{marginTop: 4, display: "flex"}}>
<div style={{flexGrow: 1}} />
Expand Down
12 changes: 8 additions & 4 deletions src/RegionSelectorSidebarBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const RowLayout = ({
header,
highlighted,
order,
classification,
name,
area,
tags,
trash,
Expand All @@ -60,7 +60,7 @@ const RowLayout = ({
<div style={{textAlign: "right", paddingRight: 10}}>{order}</div>
</Grid>
<Grid item xs={5}>
{classification}
{name}
</Grid>
<Grid item xs={2}>
<div style={{textAlign: "right", paddingRight: 6}}>{area}</div>
Expand All @@ -80,12 +80,13 @@ const RowLayout = ({
}

const RowHeader = () => {
const {t} = useTranslation();
return (
<RowLayout
header
highlighted={false}
order={<ReorderIcon className="icon" />}
classification={<div style={{paddingLeft: 10}}>Class</div>}
name={<div style={{paddingLeft: 10}}>{t("desc.class")}</div>}
area={<PieChartIcon className="icon" />}
trash={<TrashIcon className="icon" />}
lock={<LockIcon className="icon" />}
Expand All @@ -106,6 +107,7 @@ const Row = ({
locked,
color,
cls,
name,
index,
}) => {
return (
Expand All @@ -114,7 +116,7 @@ const Row = ({
highlighted={highlighted}
onClick={() => onSelectRegion(r)}
order={`#${index + 1}`}
classification={<Chip text={cls || ""} color={color || "#ddd"} />}
name={<Chip text={name || cls || ""} color={color || "#ddd"} />}
area=""
trash={<TrashIcon onClick={() => onDeleteRegion(r)} className="icon2" />}
lock={
Expand Down Expand Up @@ -156,6 +158,7 @@ const MemoRow = memo(
prevProps.id === nextProps.id &&
prevProps.index === nextProps.index &&
prevProps.cls === nextProps.cls &&
prevProps.name === nextProps.name &&
prevProps.color === nextProps.color
)

Expand Down Expand Up @@ -203,6 +206,7 @@ const mapUsedRegionProperties = (r) => [
r.color,
r.locked,
r.visible,
r.name,
r.highlighted,
]

Expand Down