From 666b3f37f34fca3622fe8e01c15fe3e64ceb39f0 Mon Sep 17 00:00:00 2001 From: Rafal Dziegielewski Date: Tue, 23 Jan 2024 09:25:20 +0100 Subject: [PATCH] fix: move bool/select value translations to labels --- .../property-type/boolean/boolean-property-value.tsx | 4 ++-- src/frontend/components/property-type/boolean/filter.tsx | 6 +++--- src/frontend/components/property-type/default-type/edit.tsx | 4 ++-- .../components/property-type/default-type/filter.tsx | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/components/property-type/boolean/boolean-property-value.tsx b/src/frontend/components/property-type/boolean/boolean-property-value.tsx index bd8f07d84..0d19184b6 100644 --- a/src/frontend/components/property-type/boolean/boolean-property-value.tsx +++ b/src/frontend/components/property-type/boolean/boolean-property-value.tsx @@ -9,7 +9,7 @@ import allowOverride from '../../../hoc/allow-override.js' const BooleanPropertyValue: React.FC = (props) => { const { record, property, resource } = props - const { translateProperty } = useTranslation() + const { tl } = useTranslation() const rawValue = record?.params[property.path] @@ -17,7 +17,7 @@ const BooleanPropertyValue: React.FC = (props) => { return null } const base = mapValue(rawValue) - const translation = translateProperty(`${property.path}.${rawValue}`, resource.id, { + const translation = tl(`${property.path}.${rawValue}`, resource.id, { defaultValue: base, }) diff --git a/src/frontend/components/property-type/boolean/filter.tsx b/src/frontend/components/property-type/boolean/filter.tsx index 73020adf6..ed71dfc87 100644 --- a/src/frontend/components/property-type/boolean/filter.tsx +++ b/src/frontend/components/property-type/boolean/filter.tsx @@ -16,11 +16,11 @@ const boolValue = (s: string): boolean => { const Filter: React.FC = (props) => { const { property, filter = {}, onChange } = props - const { tp } = useTranslation() + const { tl } = useTranslation() const value = typeof filter[property.path] === 'undefined' ? '' : boolValue(filter[property.path]) const options = [ - { value: true, label: tp(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) }, - { value: false, label: tp(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) }, + { value: true, label: tl(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) }, + { value: false, label: tl(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) }, ] const selected = options.find((o) => o.value === value) const handleChange = (s) => { diff --git a/src/frontend/components/property-type/default-type/edit.tsx b/src/frontend/components/property-type/default-type/edit.tsx index 2e7b8196f..2bffd10aa 100644 --- a/src/frontend/components/property-type/default-type/edit.tsx +++ b/src/frontend/components/property-type/default-type/edit.tsx @@ -25,7 +25,7 @@ const Edit: FC = (props) => { const SelectEdit: FC = (props) => { const { record, property, onChange } = props - const { tp } = useTranslation() + const { tl } = useTranslation() if (!property.availableValues) { return null } @@ -34,7 +34,7 @@ const SelectEdit: FC = (props) => { // eslint-disable-next-line max-len const availableValues = property.availableValues.map((v) => ({ ...v, - label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }), + label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }), })) // eslint-disable-next-line eqeqeq const selected = availableValues.find((av) => av.value == propValue) diff --git a/src/frontend/components/property-type/default-type/filter.tsx b/src/frontend/components/property-type/default-type/filter.tsx index 78da8e164..bacb9ce09 100644 --- a/src/frontend/components/property-type/default-type/filter.tsx +++ b/src/frontend/components/property-type/default-type/filter.tsx @@ -8,7 +8,7 @@ import { useTranslation } from '../../../hooks/use-translation.js' const Filter: React.FC = (props) => { const { property, onChange, filter } = props - const { tp } = useTranslation() + const { tl } = useTranslation() const handleInputChange = (event) => { onChange(property.path, event.target.value) @@ -25,7 +25,7 @@ const Filter: React.FC = (props) => { if (property.availableValues) { const availableValues = property.availableValues.map((v) => ({ ...v, - label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }), + label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }), })) const selected = property.availableValues.find((av) => av.value === value) return (