Skip to content

Commit

Permalink
fix: fix translations about thesauruses
Browse files Browse the repository at this point in the history
  • Loading branch information
botisSmile committed Sep 28, 2023
1 parent 2d2729b commit 3806671
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
8 changes: 3 additions & 5 deletions packages/components/public/locales/fr/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@
"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",
"Localized catalog(s)": "Catalogue(s) localisé(s)",
"Localized catalog": "Catalogue localisé",
"Locale": "Langue",
"Select a locale": "Sélectionnez une langue",
"Context type": "Type de contexte",
"Select a context type": "Sélectionnez un type de contexte",
"Thesaurus type": "Type du thésaurus",
"Thesaurus type": "Type de thésaurus",
"Select a thesaurus type": "Sélectionnez un type de thésaurus",
"filter.no": "Non",
"filter.yes": "Oui",
Expand Down
4 changes: 4 additions & 0 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
5 changes: 5 additions & 0 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
20 changes: 12 additions & 8 deletions packages/components/src/hooks/useOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ export function useOptions(): IOptionsContext {
(field: IField) => {
const id = field.property['@id']
return fetch(id, async (fetchApi: IFetchApi) => {
console.log('Hidden traductions', t('Hidden'))
console.log('Synonym traductions', t('Synonym'))
if (hasFieldOptions(field)) {
// get options from the schema
if (isDropdownStaticOptions(field.gally?.options)) {
// 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 @@ -65,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 3806671

Please sign in to comment.