diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 985f1b4d..dd7615ae 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -79,6 +79,74 @@ "functions-description": "Mathematical functions", "min-max-description": "Smallest/highest value" }, + "edit-type-dialog": { + "delete-field-title": "Delete field", + "delete-field-message": "Do you really want to delete the field “{{fieldName}}”?", + "delete-field-button": "Delete", + "create-type-error": "Error creating type", + "save-type-error": "Error saving type", + "field-update-error": "Error updating field", + "field-disappeared-error": "The field cannot be found on the type anymore.", + "unique-field-name-error": "Multiple fields cannot have the same name.", + "title": "Edit Type", + "name": "Name", + "type": "Type", + "type-marker": "Marker", + "type-line": "Line", + "styles-introduction": "These styles are applied when a new object of this type is created. If “Fixed” is enabled, the style is applied to all objects of this type and cannot be changed for an individual object anymore. For more complex style control, dropdown or checkbox fields can be configured below to change the style based on their selected value.", + "default-colour": "Default colour", + "fixed": "Fixed", + "default-size": "Default size", + "default-icon": "Default icon", + "default-shape": "Default shape", + "default-width": "Default width", + "default-stroke": "Default stroke", + "default-route-mode": "Default routing mode", + "legend": "Legend", + "show-in-legend": "Show in legend", + "show-in-legend-description": "An item for this type will be shown in the legend. Any fixed style attributes are applied to it. Dropdown or checkbox fields that control the style generate additional legend items.", + "field-name": "Name", + "field-type": "Type", + "field-default-value": "Default value", + "field-delete": "Delete", + "field-type-input": "Text field", + "field-type-textarea": "Text area", + "field-type-dropdown": "Dropdown", + "field-type-checkbox": "Checkbox", + "field-edit": "Edit", + "field-reorder": "Reorder", + "field-add": "Add" + }, + "edit-type-dropdown-dialog": { + "delete-option-title": "Delete option", + "delete-option-message": "Do you really want to delete the option “{{option.value}}”?", + "delete-option-button": "Delete", + "unique-value-error": "Multiple options cannot have the same label.", + "no-options-error": "Controlling fields need to have at least one option.", + "title-checkbox": "Edit Checkbox", + "title-dropdown": "Edit Dropdown", + "ok-button": "OK", + "control": "Control", + "control-interpolation-marker": "marker", + "control-interpolation-line": "line", + "control-colour": "Control {{type}} colour", + "control-size": "Control {{type}} size", + "control-icon": "Control {{type}} icon", + "control-shape": "Control {{type}} shape", + "control-width": "Control {{type}} width", + "control-stroke": "Control {{type}} stroke", + "option": "Option", + "label": "Label (for legend)", + "colour": "Colour", + "size": "Size", + "icon": "Icon", + "shape": "Shape", + "width": "Width", + "stroke": "Stroke", + "option-remove": "Remove", + "option-reorder": "Reorder", + "option-add": "Add" + }, "modal-dialog": { "close": "Close", "cancel": "Cancel", diff --git a/frontend/src/lib/components/edit-type-dialog/edit-type-dialog.vue b/frontend/src/lib/components/edit-type-dialog/edit-type-dialog.vue index 2a2ab62c..d2049bdf 100644 --- a/frontend/src/lib/components/edit-type-dialog/edit-type-dialog.vue +++ b/frontend/src/lib/components/edit-type-dialog/edit-type-dialog.vue @@ -21,11 +21,13 @@ import { injectContextRequired, requireClientContext } from "../facil-map-context-provider/facil-map-context-provider.vue"; import ValidatedField from "../ui/validated-form/validated-field.vue"; import StrokePicker from "../ui/stroke-picker.vue"; + import { useI18n } from "../../utils/i18n"; const context = injectContextRequired(); const client = requireClientContext(context); const toasts = useToasts(); + const i18n = useI18n(); const props = defineProps<{ typeId: ID | "createMarkerType" | "createLineType"; @@ -93,10 +95,10 @@ async function deleteField(field: Field): Promise { if (!await showConfirm({ - title: "Delete field", - message: `Do you really want to delete the field “${field.name}”?`, + title: i18n.t("edit-type-dialog.delete-field-title"), + message: i18n.t("edit-type-dialog.delete-field-message", { fieldName: field.name }), variant: "danger", - okLabel: "Delete" + okLabel: i18n.t("edit-type-dialog.delete-field-button") })) return; @@ -116,7 +118,11 @@ modalRef.value?.modal.hide(); } catch (err) { - toasts.showErrorToast(`fm${context.id}-edit-type-error`, isCreate.value ? "Error creating type" : "Error saving type", err); + toasts.showErrorToast( + `fm${context.id}-edit-type-error`, + isCreate.value ? i18n.t("edit-type-dialog.create-type-error") : i18n.t("edit-type-dialog.save-type-error"), + err + ); } } @@ -126,21 +132,26 @@ function handleUpdateField(field: Field) { const idx = type.value.fields.indexOf(editField.value!); - if (idx === -1) - toasts.showErrorToast(`fm${context.id}-edit-type-dropdown-error`, "Error updating field", new Error("The field cannot be found on the type anymore.")); + if (idx === -1) { + toasts.showErrorToast( + `fm${context.id}-edit-type-dropdown-error`, + i18n.t("edit-type-dialog.field-update-error"), + new Error(i18n.t("edit-type-dialog.field-disappeared-error")) + ); + } type.value.fields[idx] = field; } function validateFieldName(name: string) { if (type.value.fields.filter((field) => field.name == name).length > 1) { - return "Multiple fields cannot have the same name."; + return i18n.t("edit-type-dialog.unique-field-name-error"); } }