translation-message.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Trans, useTranslation } from 'react-i18next'
  2. import Close from './close'
  3. import usePersistedState from '../hooks/use-persisted-state'
  4. import getMeta from '../../utils/meta'
  5. function TranslationMessage() {
  6. const { t } = useTranslation()
  7. const [hidden, setHidden] = usePersistedState('hide-i18n-notification', false)
  8. const config = getMeta('ol-suggestedLanguage')!
  9. const currentUrl = getMeta('ol-currentUrl')
  10. if (hidden) {
  11. return null
  12. }
  13. return (
  14. <li className="system-message">
  15. <Close onDismiss={() => setHidden(true)} />
  16. <div className="text-center">
  17. <a href={config.url + currentUrl}>
  18. <Trans
  19. i18nKey="click_here_to_view_sl_in_lng"
  20. components={[<strong />]} // eslint-disable-line react/jsx-key
  21. values={{ lngName: config.lngName }}
  22. shouldUnescape
  23. tOptions={{ interpolation: { escapeValue: true } }}
  24. />
  25. <img
  26. className="ms-1"
  27. src={config.imgUrl}
  28. alt={t('country_flag', { country: config.lngName })}
  29. aria-hidden
  30. />
  31. </a>
  32. </div>
  33. </li>
  34. )
  35. }
  36. export default TranslationMessage