Skip to content

Commit

Permalink
fix: fix translations about thesauruses and set default value on Synoym
Browse files Browse the repository at this point in the history
and Expansion components
  • Loading branch information
botisSmile committed Sep 29, 2023
1 parent d742a5e commit 02a9a07
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
14 changes: 10 additions & 4 deletions packages/components/public/locales/fr/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
"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",
"Boost value (%)": "Valeur du boost (%)",
"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",
Expand All @@ -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"
}
3 changes: 2 additions & 1 deletion packages/components/public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions packages/components/public/locales/fr/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -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é"
}
5 changes: 3 additions & 2 deletions packages/components/public/locales/fr/thesaurus.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions packages/components/src/components/atoms/form/Expansion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down Expand Up @@ -215,8 +219,8 @@ function Expansion(props: IProps): JSX.Element {
style={{ margin: '24px 0 0 8px' }}
>
<IonIcon
style={{ fontSize: '20px', color: '#424880' }}
name="close"
style={{ fontSize: '18px', color: '#424880' }}
name="trash-outline"
/>
</IconButton>
</div>
Expand Down
9 changes: 7 additions & 2 deletions packages/components/src/components/atoms/form/Synonym.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down Expand Up @@ -191,8 +196,8 @@ function Synonym(props: IProps): JSX.Element {
style={{ marginLeft: 8 }}
>
<IonIcon
style={{ fontSize: '20px', color: '#424880' }}
name="close"
style={{ fontSize: '18px', color: '#424880' }}
name="trash-outline"
/>
</IconButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ function Grid(props: IProps): JSX.Element {

return (
<>
<PageTitle title={title ?? resourceName}>
<PageTitle title={title ?? t(resourceName)}>
{hasNewLink ? (
<Button {...propsButton}>
<CustomAHref
href={newLink ?? './create'}
isIconInButton={Boolean(propsButton?.endIcon)}
>
{t('create')} {title ?? resourceName}
{t('create')} {title ?? t(resourceName)}
</CustomAHref>
</Button>
) : null}
Expand Down
18 changes: 12 additions & 6 deletions packages/components/src/hooks/useOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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])
}

0 comments on commit 02a9a07

Please sign in to comment.