From 07a9612e9b1e4485a3307f0f591f968e09090efe Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 22 Oct 2025 09:44:30 -0600 Subject: [PATCH] Update i18n --- .../locales/en/views/classificationModel.json | 29 ++++++++++++- .../ClassificationModelWizardDialog.tsx | 29 ++++++++++--- .../wizard/Step1NameAndDefine.tsx | 43 ++++++++++--------- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/web/public/locales/en/views/classificationModel.json b/web/public/locales/en/views/classificationModel.json index dcfc5a1b2..9b86d2df5 100644 --- a/web/public/locales/en/views/classificationModel.json +++ b/web/public/locales/en/views/classificationModel.json @@ -52,6 +52,33 @@ "categorizeImage": "Classify Image", "wizard": { "title": "Create New Classification", - "description": "Create a new state or object classification model." + "description": "Create a new state or object classification model.", + "steps": { + "nameAndDefine": "Name & Define", + "stateArea": "State Area", + "chooseExamples": "Choose Examples", + "train": "Train" + }, + "step1": { + "name": "Name", + "namePlaceholder": "Enter model name...", + "type": "Type", + "typeState": "State", + "typeObject": "Object", + "classificationType": "Classification Type", + "classificationSubLabel": "Sub Label", + "classificationAttribute": "Attribute", + "classes": "Classes", + "classPlaceholder": "Enter class name...", + "errors": { + "nameRequired": "Model name is required", + "nameLength": "Model name must be 64 characters or less", + "nameOnlyNumbers": "Model name cannot contain only numbers", + "classRequired": "At least 1 class is required", + "classesUnique": "Class names must be unique", + "stateRequiresTwoClasses": "State models require at least 2 classes", + "objectTypeRequired": "Please select a classification type" + } + } } } diff --git a/web/src/components/classification/ClassificationModelWizardDialog.tsx b/web/src/components/classification/ClassificationModelWizardDialog.tsx index eaba57d08..5aded4a58 100644 --- a/web/src/components/classification/ClassificationModelWizardDialog.tsx +++ b/web/src/components/classification/ClassificationModelWizardDialog.tsx @@ -7,14 +7,20 @@ import { DialogHeader, DialogTitle, } from "../ui/dialog"; -import { useReducer } from "react"; +import { useReducer, useMemo } from "react"; import Step1NameAndDefine, { Step1FormData } from "./wizard/Step1NameAndDefine"; -const STEPS = [ - "classificationWizard.steps.nameAndDefine", - "classificationWizard.steps.stateArea", - "classificationWizard.steps.chooseExamples", - "classificationWizard.steps.train", +const OBJECT_STEPS = [ + "wizard.steps.nameAndDefine", + "wizard.steps.chooseExamples", + "wizard.steps.train", +]; + +const STATE_STEPS = [ + "wizard.steps.nameAndDefine", + "wizard.steps.stateArea", + "wizard.steps.chooseExamples", + "wizard.steps.train", ]; type ClassificationModelWizardDialogProps = { @@ -74,6 +80,15 @@ export default function ClassificationModelWizardDialog({ const [wizardState, dispatch] = useReducer(wizardReducer, initialState); + const steps = useMemo(() => { + if (!wizardState.step1Data) { + return OBJECT_STEPS; + } + return wizardState.step1Data.modelType === "state" + ? STATE_STEPS + : OBJECT_STEPS; + }, [wizardState.step1Data]); + const handleStep1Next = (data: Step1FormData) => { dispatch({ type: "SET_STEP_1", payload: data }); }; @@ -99,7 +114,7 @@ export default function ClassificationModelWizardDialog({ }} > !/^\d+$/.test(value), { - message: "Model name cannot contain only numbers", + message: t("wizard.step1.errors.nameOnlyNumbers"), }), modelType: z.enum(["state", "object"]), objectType: z.enum(["sub_label", "attribute"]).optional(), classes: z .array(z.string()) - .min(1, "At least one class field is required") + .min(1, t("wizard.step1.errors.classRequired")) .refine( (classes) => { const nonEmpty = classes.filter((c) => c.trim().length > 0); return nonEmpty.length >= 1; }, - { message: "At least 1 class is required" }, + { message: t("wizard.step1.errors.classRequired") }, ) .refine( (classes) => { @@ -64,7 +67,7 @@ export default function Step1NameAndDefine({ const unique = new Set(nonEmpty.map((c) => c.toLowerCase())); return unique.size === nonEmpty.length; }, - { message: "Class names must be unique" }, + { message: t("wizard.step1.errors.classesUnique") }, ), }) .refine( @@ -77,7 +80,7 @@ export default function Step1NameAndDefine({ return true; }, { - message: "State models require at least 2 classes", + message: t("wizard.step1.errors.stateRequiresTwoClasses"), path: ["classes"], }, ) @@ -90,7 +93,7 @@ export default function Step1NameAndDefine({ return true; }, { - message: "Please select a classification type", + message: t("wizard.step1.errors.objectTypeRequired"), path: ["objectType"], }, ); @@ -145,11 +148,11 @@ export default function Step1NameAndDefine({ name="modelName" render={({ field }) => ( - Name + {t("wizard.step1.name")} @@ -163,7 +166,7 @@ export default function Step1NameAndDefine({ name="modelType" render={({ field }) => ( - Type + {t("wizard.step1.type")}
@@ -195,7 +198,7 @@ export default function Step1NameAndDefine({ value="object" />
@@ -211,7 +214,7 @@ export default function Step1NameAndDefine({ name="objectType" render={({ field }) => ( - Classification Type + {t("wizard.step1.classificationType")}
@@ -243,7 +246,7 @@ export default function Step1NameAndDefine({ value="attribute" />
@@ -256,7 +259,7 @@ export default function Step1NameAndDefine({
- Classes + {t("wizard.step1.classes")} {watchedClasses.length > 1 && ( @@ -306,7 +309,7 @@ export default function Step1NameAndDefine({