✨(react) fix translations and add missing translations
This commit improves the translations method to handle undefined values gracefully and adds several missing translations for modals in the French locale.
This commit is contained in:
5
.changeset/warm-trees-act.md
Normal file
5
.changeset/warm-trees-act.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@openfun/cunningham-react": patch
|
||||
---
|
||||
|
||||
Fix translations method and added missing translations
|
||||
@@ -47,7 +47,10 @@ const findTranslation = (
|
||||
locale: TranslationSet,
|
||||
): string | undefined => {
|
||||
const [namespace, ...keys] = key.split(".");
|
||||
return keys.reduce((acc, subKey) => acc[subKey], (locale as any)[namespace]);
|
||||
return keys.reduce(
|
||||
(acc, subKey) => acc?.[subKey],
|
||||
(locale as any)[namespace],
|
||||
);
|
||||
};
|
||||
|
||||
export const CunninghamProvider = ({
|
||||
|
||||
@@ -46,6 +46,27 @@
|
||||
"year_select_button_aria_label": "Sélectionner une année",
|
||||
"month_select_button_aria_label": "Sélectionner un mois"
|
||||
}
|
||||
},
|
||||
"modals": {
|
||||
"helpers": {
|
||||
"delete_confirmation": {
|
||||
"title": "Êtes-vous sûr ?",
|
||||
"children": "Êtes-vous sûr de vouloir supprimer cet élément ?",
|
||||
"cancel": "Annuler",
|
||||
"delete": "Supprimer"
|
||||
},
|
||||
"confirmation": {
|
||||
"title": "Êtes-vous sûr ?",
|
||||
"children": "Êtes-vous sûr de vouloir faire cela ?",
|
||||
"cancel": "Annuler",
|
||||
"yes": "Oui"
|
||||
},
|
||||
"disclaimer": {
|
||||
"title": "Avertissement",
|
||||
"children": "Ceci est un avertissement",
|
||||
"ok": "Ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user