From 02a9a0761dd4ef5d95ee789559754b9e52874f51 Mon Sep 17 00:00:00 2001 From: Botis Date: Fri, 22 Sep 2023 17:28:10 +0200 Subject: [PATCH] fix: fix translations about thesauruses and set default value on Synoym and Expansion components --- packages/components/public/locales/fr/api.json | 14 ++++++++++---- .../components/public/locales/fr/common.json | 3 ++- .../components/public/locales/fr/options.json | 4 ++-- .../public/locales/fr/thesaurus.json | 5 +++-- .../src/components/atoms/form/Expansion.tsx | 8 ++++++-- .../src/components/atoms/form/Synonym.tsx | 9 +++++++-- .../components/stateful-pages/Grid/Grid.tsx | 4 ++-- packages/components/src/hooks/useOptions.ts | 18 ++++++++++++------ 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/packages/components/public/locales/fr/api.json b/packages/components/public/locales/fr/api.json index 71ec3e90..b06354f4 100644 --- a/packages/components/public/locales/fr/api.json +++ b/packages/components/public/locales/fr/api.json @@ -21,6 +21,7 @@ "From -99 to 100": "De -99 à 100", "Select the localized catalog(s) where the boost will be applied": "Sélection du(des) catalogue(s) localisé(s) sur le(s)quel(s) le boost sera appliqué", "Localized catalog(s)": "Catalogue(s) localisé(s)", + "Localized catalog": "Catalogue localisé", "Rule engine": "Règle virtuelle", "Add request type": "Ajouter un type de requête", "Model": "Modèle", @@ -28,11 +29,14 @@ "Request type": "Type de requête", "Type": "Type", "Terms": "Termes", - "Scope type": "Type de scope", + "Context type": "Type de contexte", "Expansions": "Expansions", "Synonyms": "Synonymes", - "Locale": "Paramètre régionaux", - "Localized catalog(s)": "Catalogue(s) localisé(s)", + "Locale": "Langue", + "Select a locale": "Sélectionnez une langue", + "Select a context type": "Sélectionnez un type de contexte", + "Thesaurus type": "Type de thésaurus", + "Select a thesaurus type": "Sélectionnez un type de thésaurus", "filter.no": "Non", "filter.yes": "Oui", "filters.apply": "Appliquer", @@ -44,5 +48,7 @@ "is": "est", "starts with": "commence par", "contains": "contient", - "ends with": "se termine par" + "ends with": "se termine par", + "Synonym": "Synonyme", + "Context": "Contexte" } diff --git a/packages/components/public/locales/fr/common.json b/packages/components/public/locales/fr/common.json index 65913e47..a25c59ac 100644 --- a/packages/components/public/locales/fr/common.json +++ b/packages/components/public/locales/fr/common.json @@ -61,5 +61,6 @@ "placeholder.default.textFieldTags": "Ajouter du texte", "All categories": "Toutes les catégories", "All search terms": "Tous les termes de recherches", - "Add": "Ajouter" + "Add": "Ajouter", + "Thesaurus": "Thésaurus" } diff --git a/packages/components/public/locales/fr/options.json b/packages/components/public/locales/fr/options.json index 99bb7355..0bbf0c1d 100644 --- a/packages/components/public/locales/fr/options.json +++ b/packages/components/public/locales/fr/options.json @@ -8,6 +8,6 @@ "Relevance": "Pertinence", "Expansion": "Expansion", "Synonym": "Synonyme", - "Locale": "Paramètre régionaux", - "Localized catalog": "Catalog localizé" + "Locale": "Langue", + "Localized catalog": "Catalog localisé" } diff --git a/packages/components/public/locales/fr/thesaurus.json b/packages/components/public/locales/fr/thesaurus.json index 4da08fd0..1143097f 100644 --- a/packages/components/public/locales/fr/thesaurus.json +++ b/packages/components/public/locales/fr/thesaurus.json @@ -1,6 +1,7 @@ { - "title.update": "Modification d’un thesaurus", - "title.create": "Création d’un thesaurus", + "Thesaurus": "Thésaurus", + "title.update": "Modification d’un thésaurus", + "title.create": "Création d’un thésaurus", "reference term": "Terme de référence", "expansion terms": "Termes étendus", "expansions": "Expansions", diff --git a/packages/components/src/components/atoms/form/Expansion.tsx b/packages/components/src/components/atoms/form/Expansion.tsx index 52ebf0be..3b1c31e8 100644 --- a/packages/components/src/components/atoms/form/Expansion.tsx +++ b/packages/components/src/components/atoms/form/Expansion.tsx @@ -87,6 +87,10 @@ function Expansion(props: IProps): JSX.Element { helperIcon, } = props + if (value.length === 0) { + onChange([{ referenceTerm: '', terms: [] }]) + } + const { t } = useTranslation('thesaurus') let lastExpansionId = 0 const expansions: IExpansionsFormatted[] = @@ -215,8 +219,8 @@ function Expansion(props: IProps): JSX.Element { style={{ margin: '24px 0 0 8px' }} > diff --git a/packages/components/src/components/atoms/form/Synonym.tsx b/packages/components/src/components/atoms/form/Synonym.tsx index 3d066b4f..8d2f9cac 100644 --- a/packages/components/src/components/atoms/form/Synonym.tsx +++ b/packages/components/src/components/atoms/form/Synonym.tsx @@ -78,6 +78,11 @@ function Synonym(props: IProps): JSX.Element { helperText, helperIcon, } = props + + if (value.length === 0) { + onChange([{ terms: [] }]) + } + const { t } = useTranslation('thesaurus') let lastExpansionId = 0 const synonyms: ISynonymFormatted[] = @@ -191,8 +196,8 @@ function Synonym(props: IProps): JSX.Element { style={{ marginLeft: 8 }} > diff --git a/packages/components/src/components/stateful-pages/Grid/Grid.tsx b/packages/components/src/components/stateful-pages/Grid/Grid.tsx index 77600725..c036404d 100644 --- a/packages/components/src/components/stateful-pages/Grid/Grid.tsx +++ b/packages/components/src/components/stateful-pages/Grid/Grid.tsx @@ -48,14 +48,14 @@ function Grid(props: IProps): JSX.Element { return ( <> - + {hasNewLink ? ( ) : null} diff --git a/packages/components/src/hooks/useOptions.ts b/packages/components/src/hooks/useOptions.ts index b6fbb66c..d81d231a 100644 --- a/packages/components/src/hooks/useOptions.ts +++ b/packages/components/src/hooks/useOptions.ts @@ -37,7 +37,7 @@ export function useOptions(): IOptionsContext { // static options const options = field.gally.options.values.map((option) => ({ ...option, - label: option?.label ? t(String(option?.label)) : undefined, + label: option?.label, })) return options } @@ -63,11 +63,17 @@ export function useOptions(): IOptionsContext { } }) }, - [api, fetch, t] + [api, fetch] ) - return useMemo( - () => ({ fieldOptions: map, load, statuses }), - [load, map, statuses] - ) + return useMemo(() => { + const mapTranslated = new Map(map) + mapTranslated.forEach((options) => + options.forEach((option) => { + option.label = t(option.label) + }) + ) + + return { fieldOptions: mapTranslated, load, statuses } + }, [load, map, statuses, t]) }