| 36 | } |
| 37 | |
| 38 | export function LanguageProvider({ |
| 39 | locale, |
| 40 | dictionary, |
| 41 | children, |
| 42 | }: LanguageProviderType) { |
| 43 | const translate = t(dictionary); |
| 44 | |
| 45 | const Translate = ({ |
| 46 | translationKey, |
| 47 | translationParams, |
| 48 | className, |
| 49 | }: { |
| 50 | translationKey: string; |
| 51 | translationParams?: TranslationPatterns; |
| 52 | className?: string; |
| 53 | html?: boolean; |
| 54 | }) => { |
| 55 | return ( |
| 56 | <div |
| 57 | className={className} |
| 58 | dangerouslySetInnerHTML={{ |
| 59 | __html: translate(translationKey, translationParams), |
| 60 | }} |
| 61 | /> |
| 62 | ); |
| 63 | }; |
| 64 | |
| 65 | const getLocaleDictionary = () => dictionary; |
| 66 | |
| 67 | return ( |
| 68 | <LanguageContext.Provider |
| 69 | value={{ locale: locale, t: translate, Translate, getLocaleDictionary }} |
| 70 | > |
| 71 | {children} |
| 72 | </LanguageContext.Provider> |
| 73 | ); |
| 74 | } |