WiP: localized categories

FIXME
This commit is contained in:
nikk gitanes
2024-04-06 12:39:03 +03:00
parent 08834e8785
commit d5699699db
12 changed files with 68 additions and 53 deletions

View File

@@ -148,11 +148,11 @@ export default function RightSideComponent({
onChange={handleCategoryChange} onChange={handleCategoryChange}
variant='outlined' variant='outlined'
fullWidth fullWidth
defaultValue='Other' defaultValue='other'
> >
{TORRENT_CATEGORIES.map(category => ( {TORRENT_CATEGORIES.map(category => (
<MenuItem key={category.name} value={category.name}> <MenuItem key={category.key} value={category.key}>
{category.name} {t(category.name)}
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>

View File

@@ -31,11 +31,18 @@ const Sidebar = ({ isDrawerOpen, setIsDonationDialogOpen, isOffline, isLoading,
<Divider /> <Divider />
<List> <List>
<FilterByCategory categoryName='All' icon={<CheckIcon />} setGlobalFilterCategory={setGlobalFilterCategory} /> <FilterByCategory
key='all'
categoryKey='all'
categoryName={t('All')}
icon={<CheckIcon />}
setGlobalFilterCategory={setGlobalFilterCategory}
/>
{TORRENT_CATEGORIES.map(category => ( {TORRENT_CATEGORIES.map(category => (
<FilterByCategory <FilterByCategory
key={category.name} key={category.key}
categoryName={category.name} categoryKey={category.key}
categoryName={t(category.name)}
icon={category.icon} icon={category.icon}
setGlobalFilterCategory={setGlobalFilterCategory} setGlobalFilterCategory={setGlobalFilterCategory}
/> />

View File

@@ -43,7 +43,7 @@ export default function App() {
const [isDarkMode, currentThemeMode, updateThemeMode, muiTheme] = useMaterialUITheme() const [isDarkMode, currentThemeMode, updateThemeMode, muiTheme] = useMaterialUITheme()
const [currentLang, changeLang] = useChangeLanguage() const [currentLang, changeLang] = useChangeLanguage()
const [isOffline, setIsOffline] = useState(false) const [isOffline, setIsOffline] = useState(false)
const [globalCategoryFilter, setGlobalFilterCategory] = useState('All') const [globalCategoryFilter, setGlobalFilterCategory] = useState('all')
const { data: torrents, isLoading } = useQuery('torrents', getTorrents, { const { data: torrents, isLoading } = useQuery('torrents', getTorrents, {
retry: 1, retry: 1,
refetchInterval: 1000, refetchInterval: 1000,

View File

@@ -1,18 +1,23 @@
import ListItem from '@material-ui/core/ListItem' import ListItem from '@material-ui/core/ListItem'
import ListItemIcon from '@material-ui/core/ListItemIcon' import ListItemIcon from '@material-ui/core/ListItemIcon'
import ListItemText from '@material-ui/core/ListItemText' import ListItemText from '@material-ui/core/ListItemText'
import { useTranslation } from 'react-i18next'
export default function FilterByCategory({ categoryName, setGlobalFilterCategory, icon }) { export default function FilterByCategory({ categoryKey, categoryName, setGlobalFilterCategory, icon }) {
const onClick = () => { const onClick = () => {
setGlobalFilterCategory(categoryName) setGlobalFilterCategory(categoryKey)
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.log('FilterByCategory categoryKey: %s categoryName: %s', categoryKey, categoryName)
} }
}
const { t } = useTranslation()
return ( return (
<> <>
<ListItem button key={categoryName} onClick={onClick}> <ListItem button key={categoryKey} onClick={onClick}>
<ListItemIcon>{icon}</ListItemIcon> <ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={t(categoryName)} />
<ListItemText primary={categoryName} />
</ListItem> </ListItem>
</> </>
) )

View File

@@ -19,6 +19,7 @@ import AddDialog from 'components/Add/AddDialog'
import { StyledDialog } from 'style/CustomMaterialUiStyles' import { StyledDialog } from 'style/CustomMaterialUiStyles'
import useOnStandaloneAppOutsideClick from 'utils/useOnStandaloneAppOutsideClick' import useOnStandaloneAppOutsideClick from 'utils/useOnStandaloneAppOutsideClick'
import { GETTING_INFO, IN_DB, CLOSED, PRELOAD, WORKING } from 'torrentStates' import { GETTING_INFO, IN_DB, CLOSED, PRELOAD, WORKING } from 'torrentStates'
import { TORRENT_CATEGORIES } from 'components/categories'
import { import {
StatusIndicators, StatusIndicators,
@@ -81,6 +82,9 @@ const Torrent = ({ torrent }) => {
const fullPlaylistLink = `${playlistTorrHost()}/${encodeURIComponent(parsedTitle || 'file')}.m3u?link=${hash}&m3u` const fullPlaylistLink = `${playlistTorrHost()}/${encodeURIComponent(parsedTitle || 'file')}.m3u?link=${hash}&m3u`
const detailedInfoDialogRef = useOnStandaloneAppOutsideClick(closeDetailedInfo) const detailedInfoDialogRef = useOnStandaloneAppOutsideClick(closeDetailedInfo)
// FIXME
const catIndex = TORRENT_CATEGORIES.findIndex(e => e.key === category)
const catArray = TORRENT_CATEGORIES.find(e => e.key === category)
return ( return (
<> <>
@@ -119,7 +123,9 @@ const Torrent = ({ torrent }) => {
<div className='description-title-wrapper'> <div className='description-title-wrapper'>
<div className='description-section-name'> <div className='description-section-name'>
{t('Name')} {t('Name')}
<div className='description-category-wrapper'>{category}</div> <div className='description-category-wrapper'>
{catIndex >= 0 ? t(catArray.name) : ''/* {category} */}
</div>
</div> </div>
<div className='description-torrent-title'>{parsedTitle}</div> <div className='description-torrent-title'>{parsedTitle}</div>
</div> </div>

View File

@@ -1,11 +1,13 @@
import TorrentCard from 'components/TorrentCard' import TorrentCard from 'components/TorrentCard'
import CircularProgress from '@material-ui/core/CircularProgress' import CircularProgress from '@material-ui/core/CircularProgress'
import { TorrentListWrapper, CenteredGrid } from 'components/App/style' import { TorrentListWrapper, CenteredGrid } from 'components/App/style'
// import { useTranslation } from 'react-i18next'
import NoServerConnection from './NoServerConnection' import NoServerConnection from './NoServerConnection'
import AddFirstTorrent from './AddFirstTorrent' import AddFirstTorrent from './AddFirstTorrent'
export default function TorrentList({ isOffline, isLoading, sortABC, torrents, sortCategory }) { export default function TorrentList({ isOffline, isLoading, sortABC, torrents, sortCategory }) {
// const { t } = useTranslation()
if (isLoading || isOffline || !torrents.length) { if (isLoading || isOffline || !torrents.length) {
return ( return (
<CenteredGrid> <CenteredGrid>
@@ -20,7 +22,7 @@ export default function TorrentList({ isOffline, isLoading, sortABC, torrents, s
) )
} }
const filteredTorrents = torrents.filter(torrent => sortCategory === 'All' || torrent.category === sortCategory) const filteredTorrents = torrents.filter(torrent => sortCategory === 'all' || torrent.category === sortCategory)
return sortABC ? ( return sortABC ? (
<TorrentListWrapper> <TorrentListWrapper>

View File

@@ -2,12 +2,10 @@ import MovieCreationIcon from '@material-ui/icons/MovieCreation'
import LiveTvIcon from '@material-ui/icons/LiveTv' import LiveTvIcon from '@material-ui/icons/LiveTv'
import MusicNoteIcon from '@material-ui/icons/MusicNote' import MusicNoteIcon from '@material-ui/icons/MusicNote'
import MoreHorizIcon from '@material-ui/icons/MoreHoriz' import MoreHorizIcon from '@material-ui/icons/MoreHoriz'
// import HelpIcon from '@material-ui/icons/Help'
export const TORRENT_CATEGORIES = [ export const TORRENT_CATEGORIES = [
{ name: 'Movies', icon: <MovieCreationIcon /> }, { key: 'movies', name: 'Movies', icon: <MovieCreationIcon /> },
{ name: 'Series', icon: <LiveTvIcon /> }, { key: 'series', name: 'Series', icon: <LiveTvIcon /> },
{ name: 'Music', icon: <MusicNoteIcon /> }, { key: 'music', name: 'Music', icon: <MusicNoteIcon /> },
{ name: 'Other', icon: <MoreHorizIcon /> }, { key: 'other', name: 'Other', icon: <MoreHorizIcon /> },
// { name: 'None', icon: <HelpIcon /> }, // TODO: unset category with this option
] ]

View File

@@ -22,6 +22,7 @@
}, },
"AddFromLink": "Добавете торент", "AddFromLink": "Добавете торент",
"AddNewTorrent": "Добавете нов торент", "AddNewTorrent": "Добавете нов торент",
"All": "Всичко",
"ApiDocs": "Документация на API", "ApiDocs": "Документация на API",
"B": "B", "B": "B",
"bps": "bps", "bps": "bps",
@@ -30,13 +31,6 @@
"Cache": "Кеш", "Cache": "Кеш",
"Cancel": "Отказ", "Cancel": "Отказ",
"Category": "Категория", "Category": "Категория",
"CategoryLabel": {
"Movies": "Филми",
"Series": "Серия",
"Music": "Музика",
"Other": "Други",
"None": "Нито един"
},
"Clear": "Изчисти", "Clear": "Изчисти",
"Close": "Затвори", "Close": "Затвори",
"CloseServer?": "Искате ли да изключите сървъра?", "CloseServer?": "Искате ли да изключите сървъра?",
@@ -75,12 +69,16 @@
"Links": "Връзки", "Links": "Връзки",
"MB": "MB", "MB": "MB",
"Mbps": "Mbps", "Mbps": "Mbps",
"Movies": "Филми",
"Music": "Музика",
"Name": "Име", "Name": "Име",
"NasReleases": "NAS Releases", "NasReleases": "NAS Releases",
"None": "Нито един",
"NoTorrentsAdded": "Няма добавени торенти", "NoTorrentsAdded": "Няма добавени торенти",
"Offline": "Извън линия", "Offline": "Извън линия",
"OK": "OK", "OK": "OK",
"OpenLink": "Отвори линк", "OpenLink": "Отвори линк",
"Other": "Други",
"Peers": "Пиъри·Сийдъри", "Peers": "Пиъри·Сийдъри",
"PiecesCount": "Брой парчета", "PiecesCount": "Брой парчета",
"PiecesLength": "Дължина на парчетата", "PiecesLength": "Дължина на парчетата",
@@ -107,6 +105,7 @@
"Sec": "сек", "Sec": "сек",
"Seconds": "Секунди", "Seconds": "Секунди",
"SelectSeason": "Избери сезон", "SelectSeason": "Избери сезон",
"Series": "Серия",
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Добавяне на ретракери", "AddRetrackers": "Добавяне на ретракери",
"AdditionalSettings": "Допълнителни настройки", "AdditionalSettings": "Допълнителни настройки",

View File

@@ -22,6 +22,7 @@
}, },
"AddFromLink": "Add Torrent", "AddFromLink": "Add Torrent",
"AddNewTorrent": "Add new torrent", "AddNewTorrent": "Add new torrent",
"All": "All",
"ApiDocs": "API Docs", "ApiDocs": "API Docs",
"B": "B", "B": "B",
"bps": "bps", "bps": "bps",
@@ -30,12 +31,6 @@
"Cache": "Cache", "Cache": "Cache",
"Cancel": "Cancel", "Cancel": "Cancel",
"Category": "Category", "Category": "Category",
"CategoryLabel": {
"Movies": "Movies",
"Series": "Series",
"Music": "Music",
"Other": "Other"
},
"Clear": "Clear", "Clear": "Clear",
"Close": "Close", "Close": "Close",
"CloseServer?": "Do you want to turn off server?", "CloseServer?": "Do you want to turn off server?",
@@ -74,12 +69,16 @@
"Links": "Links", "Links": "Links",
"MB": "MB", "MB": "MB",
"Mbps": "Mbps", "Mbps": "Mbps",
"Movies": "Movies",
"Music": "Music",
"Name": "Name", "Name": "Name",
"NasReleases": "NAS Releases", "NasReleases": "NAS Releases",
"None": "None",
"NoTorrentsAdded": "No torrents added", "NoTorrentsAdded": "No torrents added",
"Offline": "Offline", "Offline": "Offline",
"OK": "OK", "OK": "OK",
"OpenLink": "Open link", "OpenLink": "Open link",
"Other": "Other",
"Peers": "Peers·Seeds", "Peers": "Peers·Seeds",
"PiecesCount": "Pieces count", "PiecesCount": "Pieces count",
"PiecesLength": "Pieces length", "PiecesLength": "Pieces length",
@@ -106,6 +105,7 @@
"Sec": "s", "Sec": "s",
"Seconds": "Seconds", "Seconds": "Seconds",
"SelectSeason": "Select Season", "SelectSeason": "Select Season",
"Series": "Series",
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Add retrackers", "AddRetrackers": "Add retrackers",
"AdditionalSettings": "Additional Settings", "AdditionalSettings": "Additional Settings",

View File

@@ -22,6 +22,7 @@
}, },
"AddFromLink": "Добавить", "AddFromLink": "Добавить",
"AddNewTorrent": "Добавить новый торрент", "AddNewTorrent": "Добавить новый торрент",
"All": "Все",
"ApiDocs": "Документация API", "ApiDocs": "Документация API",
"B": "Б", "B": "Б",
"bps": "бит/c", "bps": "бит/c",
@@ -30,12 +31,6 @@
"Cache": "Кеш", "Cache": "Кеш",
"Cancel": "Отмена", "Cancel": "Отмена",
"Category": "Категория", "Category": "Категория",
"CategoryLabel": {
"Movies": "Фильмы",
"Series": "Сериалы",
"Music": "Музыка",
"Other": "Другое"
},
"Clear": "Очистить", "Clear": "Очистить",
"Close": "Закрыть", "Close": "Закрыть",
"CloseServer?": "Хотите выключить сервер?", "CloseServer?": "Хотите выключить сервер?",
@@ -74,12 +69,16 @@
"Links": "Ссылки", "Links": "Ссылки",
"MB": "МБ", "MB": "МБ",
"Mbps": "Мбит/c", "Mbps": "Мбит/c",
"Movies": "Фильмы",
"Music": "Музыка",
"Name": "Название", "Name": "Название",
"NasReleases": "Релизы для NAS", "NasReleases": "Релизы для NAS",
"None": "Нет",
"NoTorrentsAdded": "Нет торрентов", "NoTorrentsAdded": "Нет торрентов",
"Offline": "Сервер недоступен", "Offline": "Сервер недоступен",
"OK": "OK", "OK": "OK",
"OpenLink": "Открыть", "OpenLink": "Открыть",
"Other": "Другое",
"Peers": "Пиры·Сиды", "Peers": "Пиры·Сиды",
"PiecesCount": "Кол-во блоков", "PiecesCount": "Кол-во блоков",
"PiecesLength": "Размер блока", "PiecesLength": "Размер блока",
@@ -106,6 +105,7 @@
"Sec": "c", "Sec": "c",
"Seconds": "Секунды", "Seconds": "Секунды",
"SelectSeason": "Выбор сезона", "SelectSeason": "Выбор сезона",
"Series": "Сериалы",
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Добавлять", "AddRetrackers": "Добавлять",
"AdditionalSettings": "Расширенные настройки", "AdditionalSettings": "Расширенные настройки",

View File

@@ -22,6 +22,7 @@
}, },
"AddFromLink": "Додати торент", "AddFromLink": "Додати торент",
"AddNewTorrent": "Додати новий торент", "AddNewTorrent": "Додати новий торент",
"All": "Усе",
"ApiDocs": "Документація API", "ApiDocs": "Документація API",
"B": "Б", "B": "Б",
"bps": "біт/c", "bps": "біт/c",
@@ -30,13 +31,6 @@
"Cache": "Кеш", "Cache": "Кеш",
"Cancel": "Скасувати", "Cancel": "Скасувати",
"Category": "Категорія", "Category": "Категорія",
"CategoryLabel": {
"Movies": "Фільми",
"Series": "Серія",
"Music": "Музика",
"Other": "Інший",
"None": "Жодного"
},
"Clear": "Очистити", "Clear": "Очистити",
"Close": "Закрити", "Close": "Закрити",
"CloseServer?": "Хочете вимкнути сервер?", "CloseServer?": "Хочете вимкнути сервер?",
@@ -75,12 +69,16 @@
"Links": "Посилання", "Links": "Посилання",
"MB": "МБ", "MB": "МБ",
"Mbps": "Мбіт/c", "Mbps": "Мбіт/c",
"Movies": "Фільми",
"Music": "Музика",
"Name": "Назва", "Name": "Назва",
"NasReleases": "Релізи для NAS", "NasReleases": "Релізи для NAS",
"None": "Жодного",
"NoTorrentsAdded": "Немає торентів", "NoTorrentsAdded": "Немає торентів",
"Offline": "Сервер не доступний", "Offline": "Сервер не доступний",
"OK": "OK", "OK": "OK",
"OpenLink": "Відкрити", "OpenLink": "Відкрити",
"Other": "Інший",
"Peers": "Піри·Сіди", "Peers": "Піри·Сіди",
"PiecesCount": "К-сть блоків", "PiecesCount": "К-сть блоків",
"PiecesLength": "Розмір блоку", "PiecesLength": "Розмір блоку",
@@ -107,6 +105,7 @@
"Sec": "c", "Sec": "c",
"Seconds": "Секунди", "Seconds": "Секунди",
"SelectSeason": "Вибір сезону", "SelectSeason": "Вибір сезону",
"Series": "Серія",
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Додавати", "AddRetrackers": "Додавати",
"AdditionalSettings": "Додаткові налаштування", "AdditionalSettings": "Додаткові налаштування",

View File

@@ -22,6 +22,7 @@
}, },
"AddFromLink": "添加种子", "AddFromLink": "添加种子",
"AddNewTorrent": "添加新种子", "AddNewTorrent": "添加新种子",
"All": "全部",
"ApiDocs": "API 文档", "ApiDocs": "API 文档",
"B": "B", "B": "B",
"bps": "bps", "bps": "bps",
@@ -30,13 +31,6 @@
"Cache": "缓存", "Cache": "缓存",
"Cancel": "取消", "Cancel": "取消",
"Category": "类别", "Category": "类别",
"CategoryLabel": {
"Movies": "电影",
"Series": "系列",
"Music": "音乐",
"Other": "其他",
"None": "没有任何"
},
"Clear": "清除", "Clear": "清除",
"Close": "关闭", "Close": "关闭",
"CloseServer?": "你想关闭服务器吗?", "CloseServer?": "你想关闭服务器吗?",
@@ -75,12 +69,16 @@
"Links": "链接", "Links": "链接",
"MB": "MB", "MB": "MB",
"Mbps": "Mbps", "Mbps": "Mbps",
"Movies": "电影",
"Music": "音乐",
"Name": "名称", "Name": "名称",
"NasReleases": "NAS 版本", "NasReleases": "NAS 版本",
"None": "没有任何",
"NoTorrentsAdded": "没有添加种子", "NoTorrentsAdded": "没有添加种子",
"Offline": "离线", "Offline": "离线",
"OK": "确定", "OK": "确定",
"OpenLink": "打开链接", "OpenLink": "打开链接",
"Other": "其他",
"Peers": "Peers·Seeds", "Peers": "Peers·Seeds",
"PiecesCount": "块数量", "PiecesCount": "块数量",
"PiecesLength": "块长度", "PiecesLength": "块长度",
@@ -107,6 +105,7 @@
"Sec": "秒", "Sec": "秒",
"Seconds": "秒", "Seconds": "秒",
"SelectSeason": "选择季", "SelectSeason": "选择季",
"Series": "系列",
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "添加retrackers", "AddRetrackers": "添加retrackers",
"AdditionalSettings": "附加设置", "AdditionalSettings": "附加设置",