mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 07:25:10 -05:00
8dbf2b64f8
* Notify about unsaved changes * Move system message components and types to shared folder * Add system messages component GitOrigin-RevId: ab81a24888847bd9a8a390fd1af6b58f471f7a4b
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Trans, useTranslation } from 'react-i18next'
|
|
import Close from './close'
|
|
import usePersistedState from '../hooks/use-persisted-state'
|
|
import getMeta from '../../utils/meta'
|
|
import { SuggestedLanguage } from '../../../../types/system-message'
|
|
|
|
function TranslationMessage() {
|
|
const { t } = useTranslation()
|
|
const [hidden, setHidden] = usePersistedState('hide-i18n-notification', false)
|
|
const config = getMeta('ol-suggestedLanguage') as SuggestedLanguage
|
|
const currentUrl = getMeta('ol-currentUrl') as string
|
|
|
|
if (hidden) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<li className="system-message">
|
|
<Close onDismiss={() => setHidden(true)} />
|
|
<div className="text-center">
|
|
<a href={config.url + currentUrl}>
|
|
<Trans
|
|
i18nKey="click_here_to_view_sl_in_lng"
|
|
components={[<strong />]} // eslint-disable-line react/jsx-key
|
|
values={{ lngName: config.lngName }}
|
|
shouldUnescape
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
/>
|
|
<img
|
|
className="ms-1"
|
|
src={config.imgUrl}
|
|
alt={t('country_flag', { country: config.lngName })}
|
|
aria-hidden
|
|
/>
|
|
</a>
|
|
</div>
|
|
</li>
|
|
)
|
|
}
|
|
|
|
export default TranslationMessage
|