translate Add dialog and Close

This commit is contained in:
nikk gitanes
2021-06-05 23:15:00 +03:00
parent c046bed75b
commit e5cc07e563
5 changed files with 34 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import DialogContent from '@material-ui/core/DialogContent'
import DialogTitle from '@material-ui/core/DialogTitle' import DialogTitle from '@material-ui/core/DialogTitle'
import { torrentsHost } from 'utils/Hosts' import { torrentsHost } from 'utils/Hosts'
import axios from 'axios' import axios from 'axios'
import { useTranslation } from 'react-i18next'
export default function AddDialog({ handleClose }) { export default function AddDialog({ handleClose }) {
const [link, setLink] = useState('') const [link, setLink] = useState('')
@@ -17,23 +18,26 @@ export default function AddDialog({ handleClose }) {
const inputTitle = ({ target: { value } }) => setTitle(value) const inputTitle = ({ target: { value } }) => setTitle(value)
const inputPoster = ({ target: { value } }) => setPoster(value) const inputPoster = ({ target: { value } }) => setPoster(value)
// eslint-disable-next-line no-unused-vars
const { t } = useTranslation()
const handleSave = () => { const handleSave = () => {
axios.post(torrentsHost(), { action: 'add', link, title, poster, save_to_db: true }).finally(() => handleClose()) axios.post(torrentsHost(), { action: 'add', link, title, poster, save_to_db: true }).finally(() => handleClose())
} }
return ( return (
<Dialog open onClose={handleClose} aria-labelledby='form-dialog-title' fullWidth> <Dialog open onClose={handleClose} aria-labelledby='form-dialog-title' fullWidth>
<DialogTitle id='form-dialog-title'>Add magnet or link to torrent file</DialogTitle> <DialogTitle id='form-dialog-title'>{t('AddMagnetOrLink')}</DialogTitle>
<DialogContent> <DialogContent>
<TextField onChange={inputTitle} margin='dense' id='title' label='Title' type='text' fullWidth /> <TextField onChange={inputTitle} margin='dense' id='title' label={t('Title')} type='text' fullWidth />
<TextField onChange={inputPoster} margin='dense' id='poster' label='Poster' type='url' fullWidth /> <TextField onChange={inputPoster} margin='dense' id='poster' label={t('Poster')} type='url' fullWidth />
<TextField <TextField
onChange={inputMagnet} onChange={inputMagnet}
autoFocus autoFocus
margin='dense' margin='dense'
id='magnet' id='magnet'
label='Magnet or torrent file link' label={t('MagnetOrTorrentFileLink')}
type='text' type='text'
fullWidth fullWidth
/> />
@@ -41,11 +45,11 @@ export default function AddDialog({ handleClose }) {
<DialogActions> <DialogActions>
<Button onClick={handleClose} color='primary' variant='outlined'> <Button onClick={handleClose} color='primary' variant='outlined'>
Cancel {t('Cancel')}
</Button> </Button>
<Button variant='contained' disabled={!link} onClick={handleSave} color='primary'> <Button variant='contained' disabled={!link} onClick={handleSave} color='primary'>
Add {t('Add')}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>

View File

@@ -2,6 +2,7 @@ import Button from '@material-ui/core/Button'
import { AppBar, IconButton, makeStyles, Toolbar, Typography } from '@material-ui/core' import { AppBar, IconButton, makeStyles, Toolbar, Typography } from '@material-ui/core'
import CloseIcon from '@material-ui/icons/Close' import CloseIcon from '@material-ui/icons/Close'
import { ArrowBack } from '@material-ui/icons' import { ArrowBack } from '@material-ui/icons'
import { useTranslation } from 'react-i18next'
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
appBar: { position: 'relative' }, appBar: { position: 'relative' },
@@ -10,6 +11,8 @@ const useStyles = makeStyles(theme => ({
export default function DialogHeader({ title, onClose, onBack }) { export default function DialogHeader({ title, onClose, onBack }) {
const classes = useStyles() const classes = useStyles()
// eslint-disable-next-line no-unused-vars
const { t } = useTranslation()
return ( return (
<AppBar className={classes.appBar}> <AppBar className={classes.appBar}>
@@ -24,7 +27,7 @@ export default function DialogHeader({ title, onClose, onBack }) {
{onBack && ( {onBack && (
<Button autoFocus color='inherit' onClick={onClose}> <Button autoFocus color='inherit' onClick={onClose}>
close {t('Close')}
</Button> </Button>
)} )}
</Toolbar> </Toolbar>

View File

@@ -5,12 +5,15 @@ import TorrentCard from 'components/TorrentCard'
import axios from 'axios' import axios from 'axios'
import CircularProgress from '@material-ui/core/CircularProgress' import CircularProgress from '@material-ui/core/CircularProgress'
import { TorrentListWrapper, CenteredGrid } from 'App/style' import { TorrentListWrapper, CenteredGrid } from 'App/style'
import { useTranslation } from 'react-i18next'
export default function TorrentList() { export default function TorrentList() {
const [torrents, setTorrents] = useState([]) const [torrents, setTorrents] = useState([])
const [isLoading, setIsLoading] = useState(true) const [isLoading, setIsLoading] = useState(true)
const [isOffline, setIsOffline] = useState(true) const [isOffline, setIsOffline] = useState(true)
const timerID = useRef(-1) const timerID = useRef(-1)
// eslint-disable-next-line no-unused-vars
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
timerID.current = setInterval(() => { timerID.current = setInterval(() => {
@@ -39,9 +42,9 @@ export default function TorrentList() {
{isLoading ? ( {isLoading ? (
<CircularProgress /> <CircularProgress />
) : isOffline ? ( ) : isOffline ? (
<Typography>Offline</Typography> <Typography>{t('Offline')}</Typography>
) : ( ) : (
!torrents.length && <Typography>No torrents added</Typography> !torrents.length && <Typography>{t('NoTorrentsAdded')}</Typography>
)} )}
</CenteredGrid> </CenteredGrid>
) )

View File

@@ -1,6 +1,8 @@
{ {
"About": "About", "About": "About",
"Add": "Add",
"AddFromLink": "Add from Link", "AddFromLink": "Add from Link",
"AddMagnetOrLink": "Add magnet or link to torrent file",
"AddRetrackers": "Add retrackers", "AddRetrackers": "Add retrackers",
"Buffer": "Buffer", "Buffer": "Buffer",
"CacheSize": "Cache Size (Megabytes)", "CacheSize": "Cache Size (Megabytes)",
@@ -30,12 +32,16 @@
"Host": "Host", "Host": "Host",
"Info": "Info", "Info": "Info",
"LatestFilePlayed": "Latest file played:", "LatestFilePlayed": "Latest file played:",
"MagnetOrTorrentFileLink": "Magnet or torrent file link",
"Name": "Name", "Name": "Name",
"NoTorrentsAdded": "No torrents added",
"Offline": "Offline",
"OK": "OK", "OK": "OK",
"Peers": "Peers", "Peers": "Peers",
"PeersListenPort": "Peers Listen Port", "PeersListenPort": "Peers Listen Port",
"PEX": "PEX (Peer Exchange)", "PEX": "PEX (Peer Exchange)",
"PlaylistAll": "Playlist All", "PlaylistAll": "Playlist All",
"Poster": "Poster",
"PreloadBuffer": "Preload Buffer", "PreloadBuffer": "Preload Buffer",
"ReaderReadAHead": "Reader Read Ahead (5-100%)", "ReaderReadAHead": "Reader Read Ahead (5-100%)",
"RemoveAll": "Remove All", "RemoveAll": "Remove All",
@@ -54,6 +60,7 @@
"Speed": "Speed", "Speed": "Speed",
"TCP": "TCP (Transmission Control Protocol)", "TCP": "TCP (Transmission Control Protocol)",
"ThanksToEveryone": "Thanks to everyone who tested and helped.", "ThanksToEveryone": "Thanks to everyone who tested and helped.",
"Title": "Title",
"TorrentContent": "Torrent Content", "TorrentContent": "Torrent Content",
"TorrentDetails": "Torrent Details", "TorrentDetails": "Torrent Details",
"TorrentDisconnectTimeout": "Torrent Disconnect Timeout", "TorrentDisconnectTimeout": "Torrent Disconnect Timeout",

View File

@@ -1,6 +1,8 @@
{ {
"About": "О сервере", "About": "О сервере",
"Add": "Добавить",
"AddFromLink": "Добавить", "AddFromLink": "Добавить",
"AddMagnetOrLink": "Добавьте magnet или ссылку на торрент",
"AddRetrackers": "Добавлять", "AddRetrackers": "Добавлять",
"Buffer": "Буфер", "Buffer": "Буфер",
"CacheSize": "Размер кеша (Мегабайты)", "CacheSize": "Размер кеша (Мегабайты)",
@@ -30,12 +32,16 @@
"Host": "Хост", "Host": "Хост",
"Info": "Инфо", "Info": "Инфо",
"LatestFilePlayed": "Последний воспроизведенный файл:", "LatestFilePlayed": "Последний воспроизведенный файл:",
"MagnetOrTorrentFileLink": "Ссылка на файл торрента или magnet-ссылка",
"Name": "Имя", "Name": "Имя",
"NoTorrentsAdded": "Нет торрентов",
"Offline": "Сервер не доступен",
"OK": "OK", "OK": "OK",
"Peers": "Подкл./Пиры", "Peers": "Подкл./Пиры",
"PeersListenPort": "Порт для входящих подключений", "PeersListenPort": "Порт для входящих подключений",
"PEX": "PEX (Peer Exchange)", "PEX": "PEX (Peer Exchange)",
"PlaylistAll": "Плейлист всех", "PlaylistAll": "Плейлист всех",
"Poster": "Постер",
"PreloadBuffer": "Наполнять кеш перед началом воспроизведения", "PreloadBuffer": "Наполнять кеш перед началом воспроизведения",
"ReaderReadAHead": "Кеш предзагрузки (5-100%, рек. 95%)", "ReaderReadAHead": "Кеш предзагрузки (5-100%, рек. 95%)",
"RemoveAll": "Удалить все", "RemoveAll": "Удалить все",
@@ -54,11 +60,12 @@
"Speed": "Скорость", "Speed": "Скорость",
"TCP": "TCP (Transmission Control Protocol)", "TCP": "TCP (Transmission Control Protocol)",
"ThanksToEveryone": "Спасибо всем, кто тестировал и помогал!", "ThanksToEveryone": "Спасибо всем, кто тестировал и помогал!",
"Title": "Название",
"TorrentContent": "Содержимое торрента", "TorrentContent": "Содержимое торрента",
"TorrentDetails": "Информация о торренте", "TorrentDetails": "Информация о торренте",
"TorrentDisconnectTimeout": "Тайм-аут отключения торрента (секунды)", "TorrentDisconnectTimeout": "Тайм-аут отключения торрента (секунды)",
"TorrentsSavePath": "Путь хранения кеша", "TorrentsSavePath": "Путь хранения кеша",
"TorrentState": "Состояние", "TorrentState": "Данные торрента",
"Upload": "Отдача (не рекомендуется отключать)", "Upload": "Отдача (не рекомендуется отключать)",
"UploadFile": "Загрузить файл", "UploadFile": "Загрузить файл",
"UploadRateLimit": "Ограничение скорости отдачи (Килобайты)", "UploadRateLimit": "Ограничение скорости отдачи (Килобайты)",