add RU locale

This commit is contained in:
nikk gitanes
2021-06-04 19:32:37 +03:00
parent 92ca6d0f8f
commit 0cf0802a2f
13 changed files with 228 additions and 71 deletions

View File

@@ -8,36 +8,38 @@ import InfoIcon from '@material-ui/icons/Info'
import ListItem from '@material-ui/core/ListItem'
import ListItemIcon from '@material-ui/core/ListItemIcon'
import ListItemText from '@material-ui/core/ListItemText'
import { useTranslation } from 'react-i18next'
export default function AboutDialog() {
const [open, setOpen] = useState(false)
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
return (
<div>
<ListItem button key='Settings' onClick={() => setOpen(true)}>
<ListItemIcon>
<InfoIcon />
</ListItemIcon>
<ListItemText primary='About' />
<ListItemText primary={t('About')} />
</ListItem>
<Dialog open={open} onClose={() => setOpen(false)} aria-labelledby='form-dialog-title' fullWidth maxWidth='lg'>
<DialogTitle id='form-dialog-title'>About</DialogTitle>
<DialogTitle id='form-dialog-title'>{t('About')}</DialogTitle>
<DialogContent>
<DialogContent>
<center>
<h2>Thanks to everyone who tested and helped.</h2>
<h2>{t('ThanksToEveryone')}</h2>
</center>
<br />
<h2>Special thanks:</h2>
<b>Anacrolix Matt Joiner</b> <a href='https://github.com/anacrolix/'>github.com/anacrolix</a>
<h2>{t('SpecialThanks')}</h2>
<b>anacrolix Matt Joiner</b> <a href='https://github.com/anacrolix/'>github.com/anacrolix</a>
<br />
<b>tsynik nikk Никита</b> <a href='https://github.com/tsynik'>github.com/tsynik</a>
<b>nikk</b> <a href='https://github.com/tsynik'>github.com/tsynik</a>
<br />
<b>dancheskus</b> <a href='https://github.com/dancheskus'>github.com/dancheskus</a>
<br />
<b>Tw1cker Руслан Пахнев</b> <a href='https://github.com/Nemiroff'>github.com/Nemiroff</a>
<b>tw1cker Руслан Пахнев</b> <a href='https://github.com/Nemiroff'>github.com/Nemiroff</a>
<br />
<b>SpAwN_LMG</b>
<br />
@@ -46,7 +48,7 @@ export default function AboutDialog() {
<DialogActions>
<Button onClick={() => setOpen(false)} color='primary' variant='outlined' autoFocus>
Close
{t('Close')}
</Button>
</DialogActions>
</Dialog>

View File

@@ -3,22 +3,23 @@ import ListItemIcon from '@material-ui/core/ListItemIcon'
import LibraryAddIcon from '@material-ui/icons/LibraryAdd'
import ListItemText from '@material-ui/core/ListItemText'
import ListItem from '@material-ui/core/ListItem'
import { useTranslation } from 'react-i18next'
import AddDialog from './AddDialog'
export default function AddDialogButton() {
const [isDialogOpen, setIsDialogOpen] = useState(false)
const handleClickOpen = () => setIsDialogOpen(true)
const handleClose = () => setIsDialogOpen(false)
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
return (
<div>
<ListItem button key='Add' onClick={handleClickOpen}>
<ListItemIcon>
<LibraryAddIcon />
</ListItemIcon>
<ListItemText primary='Add from link' />
<ListItemText primary={t('AddFromLink')} />
</ListItem>
{isDialogOpen && <AddDialog handleClose={handleClose} />}

View File

@@ -6,14 +6,17 @@ import DialogActions from '@material-ui/core/DialogActions'
import List from '@material-ui/core/List'
import ButtonGroup from '@material-ui/core/ButtonGroup'
import Button from '@material-ui/core/Button'
import { useTranslation } from 'react-i18next'
const donateFrame =
'<iframe src="https://yoomoney.ru/quickpay/shop-widget?writer=seller&targets=TorrServer Donate&targets-hint=&default-sum=200&button-text=14&payment-type-choice=on&mobile-payment-type-choice=on&comment=on&hint=&successURL=&quickpay=shop&account=410013733697114" width="100%" height="302" frameborder="0" allowtransparency="true" scrolling="no"></iframe>'
export default function DonateDialog({ onClose }) {
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
return (
<Dialog open onClose={onClose} aria-labelledby='form-dialog-title' fullWidth>
<DialogTitle id='form-dialog-title'>Donate</DialogTitle>
<DialogTitle id='form-dialog-title'>{t('Donate')}</DialogTitle>
<DialogContent>
<List>
<ListItem key='DonateLinks'>

View File

@@ -5,6 +5,7 @@ import ListItemText from '@material-ui/core/ListItemText'
import DeleteIcon from '@material-ui/icons/Delete'
import { useState } from 'react'
import { torrentsHost } from 'utils/Hosts'
import { useTranslation } from 'react-i18next'
const fnRemoveAll = () => {
fetch(torrentsHost(), {
@@ -34,22 +35,23 @@ export default function RemoveAll() {
const [open, setOpen] = useState(false)
const closeDialog = () => setOpen(false)
const openDialog = () => setOpen(true)
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
return (
<>
<ListItem button key='Remove all' onClick={openDialog}>
<ListItem button key={t('RemoveAll')} onClick={openDialog}>
<ListItemIcon>
<DeleteIcon />
</ListItemIcon>
<ListItemText primary='Remove all' />
<ListItemText primary={t('RemoveAll')} />
</ListItem>
<Dialog open={open} onClose={closeDialog}>
<DialogTitle>Delete Torrent?</DialogTitle>
<DialogTitle>{t('DeleteTorrents?')}</DialogTitle>
<DialogActions>
<Button variant='outlined' onClick={closeDialog} color='primary'>
Cancel
{t('Cancel')}
</Button>
<Button
@@ -61,7 +63,7 @@ export default function RemoveAll() {
color='primary'
autoFocus
>
Ok
{t('OK')}
</Button>
</DialogActions>
</Dialog>

View File

@@ -12,6 +12,7 @@ import Button from '@material-ui/core/Button'
import { FormControlLabel, InputLabel, Select, Switch } from '@material-ui/core'
import { settingsHost, setTorrServerHost, getTorrServerHost } from 'utils/Hosts'
import axios from 'axios'
import { useTranslation } from 'react-i18next'
export default function SettingsDialog() {
const [open, setOpen] = useState(false)
@@ -27,6 +28,8 @@ export default function SettingsDialog() {
sets.CacheSize *= 1024 * 1024
axios.post(settingsHost(), { action: 'set', sets })
}
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
useEffect(() => {
axios
@@ -82,21 +85,21 @@ export default function SettingsDialog() {
return (
<div>
<ListItem button key='Settings' onClick={handleClickOpen}>
<ListItem button key={t('Settings')} onClick={handleClickOpen}>
<ListItemIcon>
<SettingsIcon />
</ListItemIcon>
<ListItemText primary='Settings' />
<ListItemText primary={t('Settings')} />
</ListItem>
<Dialog open={open} onClose={handleClose} aria-labelledby='form-dialog-title' fullWidth>
<DialogTitle id='form-dialog-title'>Settings</DialogTitle>
<DialogTitle id='form-dialog-title'>{t('Settings')}</DialogTitle>
<DialogContent>
<TextField
onChange={onInputHost}
margin='dense'
id='TorrServerHost'
label='Host'
label={t('Host')}
value={tsHost}
type='url'
fullWidth
@@ -107,87 +110,87 @@ export default function SettingsDialog() {
onChange={inputForm}
margin='dense'
id='CacheSize'
label='Cache size'
label={t('CacheSize')}
value={CacheSize}
type='number'
fullWidth
/>
<FormControlLabel
control={<Switch checked={PreloadBuffer} onChange={inputForm} id='PreloadBuffer' color='primary' />}
label='Preload buffer'
label={t('PreloadBuffer')}
/>
<TextField
onChange={inputForm}
margin='dense'
id='ReaderReadAHead'
label='Reader readahead'
label={t('ReaderReadAHead')}
value={ReaderReadAHead}
type='number'
fullWidth
/>
<br />
<br />
<InputLabel htmlFor='RetrackersMode'>Retracker mode</InputLabel>
<InputLabel htmlFor='RetrackersMode'>{t('RetrackersMode')}</InputLabel>
<Select onChange={inputForm} type='number' native id='RetrackersMode' value={RetrackersMode}>
<option value={0}>Don&apos;t add retrackers</option>
<option value={1}>Add retrackers</option>
<option value={2}>Remove retrackers</option>
<option value={3}>Replace retrackers</option>
<option value={0}>{t('DontAddRetrackers')}</option>
<option value={1}>{t('AddRetrackers')}</option>
<option value={2}>{t('RemoveRetrackers')}</option>
<option value={3}>{t('ReplaceRetrackers')}</option>
</Select>
<TextField
onChange={inputForm}
margin='dense'
id='TorrentDisconnectTimeout'
label='Torrent disconnect timeout'
label={t('TorrentDisconnectTimeout')}
value={TorrentDisconnectTimeout}
type='number'
fullWidth
/>
<FormControlLabel
control={<Switch checked={EnableIPv6} onChange={inputForm} id='EnableIPv6' color='primary' />}
label='Enable IPv6'
label={t('EnableIPv6')}
/>
<br />
<FormControlLabel
control={<Switch checked={ForceEncrypt} onChange={inputForm} id='ForceEncrypt' color='primary' />}
label='Force encrypt'
label={t('ForceEncrypt')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisableTCP} onChange={inputForm} id='DisableTCP' color='primary' />}
label='Disable TCP'
label={t('DisableTCP')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisableUTP} onChange={inputForm} id='DisableUTP' color='primary' />}
label='Disable UTP'
label={t('DisableUTP')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisableUPNP} onChange={inputForm} id='DisableUPNP' color='primary' />}
label='Disable UPNP'
label={t('DisableUPNP')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisableDHT} onChange={inputForm} id='DisableDHT' color='primary' />}
label='Disable DHT'
label={t('DisableDHT')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisablePEX} onChange={inputForm} id='DisablePEX' color='primary' />}
label='Disable PEX'
label={t('DisablePEX')}
/>
<br />
<FormControlLabel
control={<Switch checked={DisableUpload} onChange={inputForm} id='DisableUpload' color='primary' />}
label='Disable upload'
label={t('DisableUpload')}
/>
<br />
<TextField
onChange={inputForm}
margin='dense'
id='DownloadRateLimit'
label='Download rate limit'
label={t('DownloadRateLimit')}
value={DownloadRateLimit}
type='number'
fullWidth
@@ -196,7 +199,7 @@ export default function SettingsDialog() {
onChange={inputForm}
margin='dense'
id='UploadRateLimit'
label='Upload rate limit'
label={t('UploadRateLimit')}
value={UploadRateLimit}
type='number'
fullWidth
@@ -205,7 +208,7 @@ export default function SettingsDialog() {
onChange={inputForm}
margin='dense'
id='ConnectionsLimit'
label='Connections limit'
label={t('ConnectionsLimit')}
value={ConnectionsLimit}
type='number'
fullWidth
@@ -214,7 +217,7 @@ export default function SettingsDialog() {
onChange={inputForm}
margin='dense'
id='DhtConnectionLimit'
label='Dht connection limit'
label={t('DhtConnectionLimit')}
value={DhtConnectionLimit}
type='number'
fullWidth
@@ -223,7 +226,7 @@ export default function SettingsDialog() {
onChange={inputForm}
margin='dense'
id='PeersListenPort'
label='Peers listen port'
label={t('PeersListenPort')}
value={PeersListenPort}
type='number'
fullWidth
@@ -231,23 +234,23 @@ export default function SettingsDialog() {
<br />
<FormControlLabel
control={<Switch checked={UseDisk} onChange={inputForm} id='UseDisk' color='primary' />}
label='Use disk'
label={t('UseDisk')}
/>
<br />
<FormControlLabel
control={
<Switch checked={RemoveCacheOnDrop} onChange={inputForm} id='RemoveCacheOnDrop' color='primary' />
}
label='Remove cache from disk on drop torrent'
label={t('RemoveCacheOnDrop')}
/>
<br />
<small>If disabled, remove cache on delete torrent</small>
<small>{t('RemoveCacheOnDropDesc')}</small>
<br />
<TextField
onChange={inputForm}
margin='dense'
id='TorrentsSavePath'
label='Torrents save path'
label={t('TorrentsSavePath')}
value={TorrentsSavePath}
type='url'
fullWidth
@@ -258,11 +261,11 @@ export default function SettingsDialog() {
<DialogActions>
<Button onClick={handleClose} color='primary' variant='outlined'>
Cancel
{t('Cancel')}
</Button>
<Button onClick={handleSave} color='primary' variant='outlined'>
Save
{t('Save')}
</Button>
</DialogActions>
</Dialog>

View File

@@ -10,12 +10,15 @@ import Slide from '@material-ui/core/Slide'
import { Button, DialogActions, DialogTitle, useMediaQuery, useTheme } from '@material-ui/core'
import axios from 'axios'
import ptt from 'parse-torrent-title'
import { useTranslation } from 'react-i18next'
import { StyledButton, TorrentCard, TorrentCardButtons, TorrentCardDescription, TorrentCardPoster } from './style'
const Transition = forwardRef((props, ref) => <Slide direction='up' ref={ref} {...props} />)
export default function Torrent({ torrent }) {
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
const [isDetailedInfoOpened, setIsDetailedInfoOpened] = useState(false)
const [isDeleteTorrentOpened, setIsDeleteTorrentOpened] = useState(false)
@@ -44,41 +47,41 @@ export default function Torrent({ torrent }) {
<TorrentCardButtons>
<StyledButton onClick={openDetailedInfo}>
<UnfoldMoreIcon />
<span>Details</span>
<span>{t('Details')}</span>
</StyledButton>
<StyledButton onClick={() => dropTorrent(torrent)}>
<CloseIcon />
<span>Drop</span>
<span>{t('Drop')}</span>
</StyledButton>
<StyledButton onClick={openDeleteTorrentAlert}>
<DeleteIcon />
<span>Delete</span>
<span>{t('Delete')}</span>
</StyledButton>
</TorrentCardButtons>
<TorrentCardDescription>
<div className='description-title-wrapper'>
<div className='description-section-name'>Name</div>
<div className='description-section-name'>{t('Name')}</div>
<div className='description-torrent-title'>{shortenText(parsedTitle, 100)}</div>
</div>
<div className='description-statistics-wrapper'>
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>Size</div>
<div className='description-section-name'>{t('Size')}</div>
<div className='description-statistics-element-value'>{torrentSize > 0 && humanizeSize(torrentSize)}</div>
</div>
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>Speed</div>
<div className='description-section-name'>{t('Speed')}</div>
<div className='description-statistics-element-value'>
{downloadSpeed > 0 ? humanizeSize(downloadSpeed) : '---'}
</div>
</div>
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>Peers</div>
<div className='description-section-name'>{t('Peers')}</div>
<div className='description-statistics-element-value'>{getPeerString(torrent) || '---'}</div>
</div>
</div>
@@ -97,10 +100,10 @@ export default function Torrent({ torrent }) {
</Dialog>
<Dialog open={isDeleteTorrentOpened} onClose={closeDeleteTorrentAlert}>
<DialogTitle>Delete Torrent?</DialogTitle>
<DialogTitle>{t('DeleteTorrent?')}</DialogTitle>
<DialogActions>
<Button variant='outlined' onClick={closeDeleteTorrentAlert} color='primary'>
Cancel
{t('Cancel')}
</Button>
<Button
@@ -112,7 +115,7 @@ export default function Torrent({ torrent }) {
color='primary'
autoFocus
>
Ok
{t('OK')}
</Button>
</DialogActions>
</Dialog>

View File

@@ -4,6 +4,7 @@ import ListItem from '@material-ui/core/ListItem'
import PublishIcon from '@material-ui/icons/Publish'
import { torrentUploadHost } from 'utils/Hosts'
import axios from 'axios'
import { useTranslation } from 'react-i18next'
export default function UploadDialog() {
const handleCapture = ({ target: { files } }) => {
@@ -13,18 +14,19 @@ export default function UploadDialog() {
data.append('file', file)
axios.post(torrentUploadHost(), data)
}
// eslint-disable-next-line no-unused-vars
const { t, i18n } = useTranslation('translations')
return (
<div>
<label htmlFor='raised-button-file'>
<input onChange={handleCapture} accept='*/*' type='file' style={{ display: 'none' }} id='raised-button-file' />
<ListItem button variant='raised' type='submit' component='span' key='Upload file'>
<ListItem button variant='raised' type='submit' component='span' key={t('UploadFile')}>
<ListItemIcon>
<PublishIcon />
</ListItemIcon>
<ListItemText primary='Upload file' />
<ListItemText primary={t('UploadFile')} />
</ListItem>
</label>
</div>