All files / components/providers/IntlProviderWrapper IntlProviderWrapper.tsx

0% Statements 0/3
100% Branches 0/0
0% Functions 0/1
0% Lines 0/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
import { IntlProvider } from 'react-intl';
import { useSelector } from 'react-redux';
import { selectLanguage } from '@/store/reducers/settings/settings-selectors';
import translationsEn from '@/translations/translations-en.json';
import translationsHu from '@/translations/translations-hu.json';
import { Language } from '@/enums/settings';
import { ReactNode } from 'react';
 
const messages: Record<Language, Record<string, string>> = {
  [Language.English]: translationsEn,
  [Language.Hungarian]: translationsHu,
};
 
interface IntlProviderWrapperProps {
  children: ReactNode;
}
 
function IntlProviderWrapper({ children }: IntlProviderWrapperProps) {
  const language = useSelector(selectLanguage);
 
  return (
    <IntlProvider locale={language} messages={messages[language]}>
      {children}
    </IntlProvider>
  );
}
 
export default IntlProviderWrapper;