2022-09-07 10:30:14 +00:00
import { useI18n as useI18nBase } from "keycloakify" ;
type Props = Omit < Parameters < typeof useI18nBase > [ 0 ] , "extraMessages" > ;
export function useI18n ( props : Props ) {
const { kcContext } = props ;
return useI18nBase ( {
kcContext ,
2023-03-04 15:14:31 +00:00
// NOTE: Here you can override the default i18n messages
// or define new ones that, for example, you would have
// defined in the Keycloak admin UI for UserProfile
// https://user-images.githubusercontent.com/6702424/182050652-522b6fe6-8ee5-49df-aca3-dba2d33f24a5.png
2022-09-07 10:30:14 +00:00
"extraMessages" : {
"en" : {
"alphanumericalCharsOnly" : "Only alphanumerical characters" ,
2023-02-26 16:21:45 +00:00
"gender" : "Gender" ,
// Here we overwrite the default english value for the message "doForgotPassword"
2022-09-07 10:30:14 +00:00
// that is "Forgot Password?" see: https://github.com/InseeFrLab/keycloakify/blob/f0ae5ea908e0aa42391af323b6d5e2fd371af851/src/lib/i18n/generated_messages/18.0.1/login/en.ts#L17
2023-01-27 14:54:00 +00:00
"doForgotPassword" : "I forgot my password" ,
2022-09-07 10:30:14 +00:00
} ,
"fr" : {
/* spell-checker: disable */
"alphanumericalCharsOnly" : "Caractère alphanumérique uniquement" ,
2023-02-26 16:21:45 +00:00
"gender" : "Genre" ,
"doForgotPassword" : "J'ai oublié mon mot de passe"
2022-09-07 10:30:14 +00:00
/* spell-checker: enable */
} ,
} ,
} ) ;
}
2023-02-08 12:55:07 +00:00
export type I18n = NonNullable < ReturnType < typeof useI18n > > ;