mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 05:56:10 +05:00
simplify i18n
This commit is contained in:
@@ -20,7 +20,7 @@ import { AppSidebarStyle } from './style'
|
|||||||
|
|
||||||
export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) {
|
export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<AppSidebarStyle isDrawerOpen={isDrawerOpen}>
|
<AppSidebarStyle isDrawerOpen={isDrawerOpen}>
|
||||||
<List>
|
<List>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'
|
|||||||
export default function AboutDialog() {
|
export default function AboutDialog() {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ListItem button key='Settings' onClick={() => setOpen(true)}>
|
<ListItem button key='Settings' onClick={() => setOpen(true)}>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function AddDialogButton() {
|
|||||||
const handleClickOpen = () => setIsDialogOpen(true)
|
const handleClickOpen = () => setIsDialogOpen(true)
|
||||||
const handleClose = () => setIsDialogOpen(false)
|
const handleClose = () => setIsDialogOpen(false)
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ListItem button key='Add' onClick={handleClickOpen}>
|
<ListItem button key='Add' onClick={handleClickOpen}>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const donateFrame =
|
|||||||
|
|
||||||
export default function DonateDialog({ onClose }) {
|
export default function DonateDialog({ onClose }) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<Dialog open onClose={onClose} aria-labelledby='form-dialog-title' fullWidth>
|
<Dialog open onClose={onClose} aria-labelledby='form-dialog-title' fullWidth>
|
||||||
<DialogTitle id='form-dialog-title'>{t('Donate')}</DialogTitle>
|
<DialogTitle id='form-dialog-title'>{t('Donate')}</DialogTitle>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default function RemoveAll() {
|
|||||||
const closeDialog = () => setOpen(false)
|
const closeDialog = () => setOpen(false)
|
||||||
const openDialog = () => setOpen(true)
|
const openDialog = () => setOpen(true)
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ListItem button key={t('RemoveAll')} onClick={openDialog}>
|
<ListItem button key={t('RemoveAll')} onClick={openDialog}>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function SettingsDialog() {
|
|||||||
axios.post(settingsHost(), { action: 'set', sets })
|
axios.post(settingsHost(), { action: 'set', sets })
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axios
|
axios
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const Transition = forwardRef((props, ref) => <Slide direction='up' ref={ref} {.
|
|||||||
|
|
||||||
export default function Torrent({ torrent }) {
|
export default function Torrent({ torrent }) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
const [isDetailedInfoOpened, setIsDetailedInfoOpened] = useState(false)
|
const [isDetailedInfoOpened, setIsDetailedInfoOpened] = useState(false)
|
||||||
const [isDeleteTorrentOpened, setIsDeleteTorrentOpened] = useState(false)
|
const [isDeleteTorrentOpened, setIsDeleteTorrentOpened] = useState(false)
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default function UploadDialog() {
|
|||||||
axios.post(torrentUploadHost(), data)
|
axios.post(torrentUploadHost(), data)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { t, i18n } = useTranslation('translations')
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor='raised-button-file'>
|
<label htmlFor='raised-button-file'>
|
||||||
|
|||||||
@@ -3,34 +3,32 @@ import ReactDOM from 'react-dom'
|
|||||||
import { I18nextProvider } from 'react-i18next'
|
import { I18nextProvider } from 'react-i18next'
|
||||||
import i18n from 'i18next'
|
import i18n from 'i18next'
|
||||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||||
import XHR from 'i18next-xhr-backend'
|
|
||||||
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import translationEng from './locales/en/translation.json'
|
|
||||||
import translationRus from './locales/ru/translation.json'
|
|
||||||
|
|
||||||
i18n
|
i18n.use(LanguageDetector).init({
|
||||||
.use(XHR)
|
lng: 'ru', // default
|
||||||
.use(LanguageDetector)
|
fallbackLng: 'en', // use en if detected lng is not available
|
||||||
.init({
|
keySeparator: false, // we do not use keys in form messages.welcome
|
||||||
lng: 'ru', // default
|
interpolation: {
|
||||||
fallbackLng: 'en', // use en if detected lng is not available
|
escapeValue: false, // react already safes from xss
|
||||||
keySeparator: false, // we do not use keys in form messages.welcome
|
},
|
||||||
interpolation: {
|
resources: {
|
||||||
escapeValue: false, // react already safes from xss
|
en: {
|
||||||
|
// eslint-disable-next-line global-require
|
||||||
|
translations: require('./locales/en/translation.json'),
|
||||||
},
|
},
|
||||||
resources: {
|
ru: {
|
||||||
en: {
|
// eslint-disable-next-line global-require
|
||||||
translations: translationEng,
|
translations: require('./locales/ru/translation.json'),
|
||||||
},
|
|
||||||
ru: {
|
|
||||||
translations: translationRus,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ns: ['translations'],
|
},
|
||||||
defaultNS: 'translations',
|
ns: ['translations'],
|
||||||
})
|
defaultNS: 'translations',
|
||||||
|
})
|
||||||
|
|
||||||
|
i18n.languages = ['en', 'ru']
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|||||||
Reference in New Issue
Block a user