diff --git a/web/src/components/Add/RightSideComponent.jsx b/web/src/components/Add/RightSideComponent.jsx index 378ab52..d84f1bd 100644 --- a/web/src/components/Add/RightSideComponent.jsx +++ b/web/src/components/Add/RightSideComponent.jsx @@ -148,11 +148,11 @@ export default function RightSideComponent({ onChange={handleCategoryChange} variant='outlined' fullWidth - defaultValue='Other' + defaultValue='other' > {TORRENT_CATEGORIES.map(category => ( - - {category.name} + + {t(category.name)} ))} diff --git a/web/src/components/App/Sidebar.jsx b/web/src/components/App/Sidebar.jsx index 7550b1f..06d3cef 100644 --- a/web/src/components/App/Sidebar.jsx +++ b/web/src/components/App/Sidebar.jsx @@ -31,11 +31,18 @@ const Sidebar = ({ isDrawerOpen, setIsDonationDialogOpen, isOffline, isLoading, - } setGlobalFilterCategory={setGlobalFilterCategory} /> + } + setGlobalFilterCategory={setGlobalFilterCategory} + /> {TORRENT_CATEGORIES.map(category => ( diff --git a/web/src/components/App/index.jsx b/web/src/components/App/index.jsx index c7658ae..4593203 100644 --- a/web/src/components/App/index.jsx +++ b/web/src/components/App/index.jsx @@ -43,7 +43,7 @@ export default function App() { const [isDarkMode, currentThemeMode, updateThemeMode, muiTheme] = useMaterialUITheme() const [currentLang, changeLang] = useChangeLanguage() const [isOffline, setIsOffline] = useState(false) - const [globalCategoryFilter, setGlobalFilterCategory] = useState('All') + const [globalCategoryFilter, setGlobalFilterCategory] = useState('all') const { data: torrents, isLoading } = useQuery('torrents', getTorrents, { retry: 1, refetchInterval: 1000, diff --git a/web/src/components/FilterByCategory.jsx b/web/src/components/FilterByCategory.jsx index 2735cc3..64afd10 100644 --- a/web/src/components/FilterByCategory.jsx +++ b/web/src/components/FilterByCategory.jsx @@ -1,18 +1,23 @@ 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 FilterByCategory({ categoryName, setGlobalFilterCategory, icon }) { +export default function FilterByCategory({ categoryKey, categoryName, setGlobalFilterCategory, icon }) { 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 ( <> - + {icon} - - + ) diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index da2c338..3fdb31a 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -19,6 +19,7 @@ import AddDialog from 'components/Add/AddDialog' import { StyledDialog } from 'style/CustomMaterialUiStyles' import useOnStandaloneAppOutsideClick from 'utils/useOnStandaloneAppOutsideClick' import { GETTING_INFO, IN_DB, CLOSED, PRELOAD, WORKING } from 'torrentStates' +import { TORRENT_CATEGORIES } from 'components/categories' import { StatusIndicators, @@ -81,6 +82,9 @@ const Torrent = ({ torrent }) => { const fullPlaylistLink = `${playlistTorrHost()}/${encodeURIComponent(parsedTitle || 'file')}.m3u?link=${hash}&m3u` const detailedInfoDialogRef = useOnStandaloneAppOutsideClick(closeDetailedInfo) + // FIXME + const catIndex = TORRENT_CATEGORIES.findIndex(e => e.key === category) + const catArray = TORRENT_CATEGORIES.find(e => e.key === category) return ( <> @@ -119,7 +123,9 @@ const Torrent = ({ torrent }) => {
{t('Name')} -
{category}
+
+ {catIndex >= 0 ? t(catArray.name) : ''/* {category} */} +
{parsedTitle}
diff --git a/web/src/components/TorrentList/index.jsx b/web/src/components/TorrentList/index.jsx index e0362dc..4ccd090 100644 --- a/web/src/components/TorrentList/index.jsx +++ b/web/src/components/TorrentList/index.jsx @@ -1,11 +1,13 @@ import TorrentCard from 'components/TorrentCard' import CircularProgress from '@material-ui/core/CircularProgress' import { TorrentListWrapper, CenteredGrid } from 'components/App/style' +// import { useTranslation } from 'react-i18next' import NoServerConnection from './NoServerConnection' import AddFirstTorrent from './AddFirstTorrent' export default function TorrentList({ isOffline, isLoading, sortABC, torrents, sortCategory }) { + // const { t } = useTranslation() if (isLoading || isOffline || !torrents.length) { return ( @@ -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 ? ( diff --git a/web/src/components/categories.jsx b/web/src/components/categories.jsx index 91eacd0..f9a1556 100644 --- a/web/src/components/categories.jsx +++ b/web/src/components/categories.jsx @@ -2,12 +2,10 @@ import MovieCreationIcon from '@material-ui/icons/MovieCreation' import LiveTvIcon from '@material-ui/icons/LiveTv' import MusicNoteIcon from '@material-ui/icons/MusicNote' import MoreHorizIcon from '@material-ui/icons/MoreHoriz' -// import HelpIcon from '@material-ui/icons/Help' export const TORRENT_CATEGORIES = [ - { name: 'Movies', icon: }, - { name: 'Series', icon: }, - { name: 'Music', icon: }, - { name: 'Other', icon: }, - // { name: 'None', icon: }, // TODO: unset category with this option + { key: 'movies', name: 'Movies', icon: }, + { key: 'series', name: 'Series', icon: }, + { key: 'music', name: 'Music', icon: }, + { key: 'other', name: 'Other', icon: }, ] diff --git a/web/src/locales/bg/translation.json b/web/src/locales/bg/translation.json index bf6c3af..4a51584 100644 --- a/web/src/locales/bg/translation.json +++ b/web/src/locales/bg/translation.json @@ -22,6 +22,7 @@ }, "AddFromLink": "Добавете торент", "AddNewTorrent": "Добавете нов торент", + "All": "Всичко", "ApiDocs": "Документация на API", "B": "B", "bps": "bps", @@ -30,13 +31,6 @@ "Cache": "Кеш", "Cancel": "Отказ", "Category": "Категория", - "CategoryLabel": { - "Movies": "Филми", - "Series": "Серия", - "Music": "Музика", - "Other": "Други", - "None": "Нито един" - }, "Clear": "Изчисти", "Close": "Затвори", "CloseServer?": "Искате ли да изключите сървъра?", @@ -75,12 +69,16 @@ "Links": "Връзки", "MB": "MB", "Mbps": "Mbps", + "Movies": "Филми", + "Music": "Музика", "Name": "Име", "NasReleases": "NAS Releases", + "None": "Нито един", "NoTorrentsAdded": "Няма добавени торенти", "Offline": "Извън линия", "OK": "OK", "OpenLink": "Отвори линк", + "Other": "Други", "Peers": "Пиъри·Сийдъри", "PiecesCount": "Брой парчета", "PiecesLength": "Дължина на парчетата", @@ -107,6 +105,7 @@ "Sec": "сек", "Seconds": "Секунди", "SelectSeason": "Избери сезон", + "Series": "Серия", "SettingsDialog": { "AddRetrackers": "Добавяне на ретракери", "AdditionalSettings": "Допълнителни настройки", diff --git a/web/src/locales/en/translation.json b/web/src/locales/en/translation.json index 14f6fb8..a072dcb 100644 --- a/web/src/locales/en/translation.json +++ b/web/src/locales/en/translation.json @@ -22,6 +22,7 @@ }, "AddFromLink": "Add Torrent", "AddNewTorrent": "Add new torrent", + "All": "All", "ApiDocs": "API Docs", "B": "B", "bps": "bps", @@ -30,12 +31,6 @@ "Cache": "Cache", "Cancel": "Cancel", "Category": "Category", - "CategoryLabel": { - "Movies": "Movies", - "Series": "Series", - "Music": "Music", - "Other": "Other" - }, "Clear": "Clear", "Close": "Close", "CloseServer?": "Do you want to turn off server?", @@ -74,12 +69,16 @@ "Links": "Links", "MB": "MB", "Mbps": "Mbps", + "Movies": "Movies", + "Music": "Music", "Name": "Name", "NasReleases": "NAS Releases", + "None": "None", "NoTorrentsAdded": "No torrents added", "Offline": "Offline", "OK": "OK", "OpenLink": "Open link", + "Other": "Other", "Peers": "Peers·Seeds", "PiecesCount": "Pieces count", "PiecesLength": "Pieces length", @@ -106,6 +105,7 @@ "Sec": "s", "Seconds": "Seconds", "SelectSeason": "Select Season", + "Series": "Series", "SettingsDialog": { "AddRetrackers": "Add retrackers", "AdditionalSettings": "Additional Settings", diff --git a/web/src/locales/ru/translation.json b/web/src/locales/ru/translation.json index 0d55544..f0cb999 100644 --- a/web/src/locales/ru/translation.json +++ b/web/src/locales/ru/translation.json @@ -22,6 +22,7 @@ }, "AddFromLink": "Добавить", "AddNewTorrent": "Добавить новый торрент", + "All": "Все", "ApiDocs": "Документация API", "B": "Б", "bps": "бит/c", @@ -30,12 +31,6 @@ "Cache": "Кеш", "Cancel": "Отмена", "Category": "Категория", - "CategoryLabel": { - "Movies": "Фильмы", - "Series": "Сериалы", - "Music": "Музыка", - "Other": "Другое" - }, "Clear": "Очистить", "Close": "Закрыть", "CloseServer?": "Хотите выключить сервер?", @@ -74,12 +69,16 @@ "Links": "Ссылки", "MB": "МБ", "Mbps": "Мбит/c", + "Movies": "Фильмы", + "Music": "Музыка", "Name": "Название", "NasReleases": "Релизы для NAS", + "None": "Нет", "NoTorrentsAdded": "Нет торрентов", "Offline": "Сервер недоступен", "OK": "OK", "OpenLink": "Открыть", + "Other": "Другое", "Peers": "Пиры·Сиды", "PiecesCount": "Кол-во блоков", "PiecesLength": "Размер блока", @@ -106,6 +105,7 @@ "Sec": "c", "Seconds": "Секунды", "SelectSeason": "Выбор сезона", + "Series": "Сериалы", "SettingsDialog": { "AddRetrackers": "Добавлять", "AdditionalSettings": "Расширенные настройки", diff --git a/web/src/locales/ua/translation.json b/web/src/locales/ua/translation.json index b40dec1..99c4de5 100644 --- a/web/src/locales/ua/translation.json +++ b/web/src/locales/ua/translation.json @@ -22,6 +22,7 @@ }, "AddFromLink": "Додати торент", "AddNewTorrent": "Додати новий торент", + "All": "Усе", "ApiDocs": "Документація API", "B": "Б", "bps": "біт/c", @@ -30,13 +31,6 @@ "Cache": "Кеш", "Cancel": "Скасувати", "Category": "Категорія", - "CategoryLabel": { - "Movies": "Фільми", - "Series": "Серія", - "Music": "Музика", - "Other": "Інший", - "None": "Жодного" - }, "Clear": "Очистити", "Close": "Закрити", "CloseServer?": "Хочете вимкнути сервер?", @@ -75,12 +69,16 @@ "Links": "Посилання", "MB": "МБ", "Mbps": "Мбіт/c", + "Movies": "Фільми", + "Music": "Музика", "Name": "Назва", "NasReleases": "Релізи для NAS", + "None": "Жодного", "NoTorrentsAdded": "Немає торентів", "Offline": "Сервер не доступний", "OK": "OK", "OpenLink": "Відкрити", + "Other": "Інший", "Peers": "Піри·Сіди", "PiecesCount": "К-сть блоків", "PiecesLength": "Розмір блоку", @@ -107,6 +105,7 @@ "Sec": "c", "Seconds": "Секунди", "SelectSeason": "Вибір сезону", + "Series": "Серія", "SettingsDialog": { "AddRetrackers": "Додавати", "AdditionalSettings": "Додаткові налаштування", diff --git a/web/src/locales/zh/translation.json b/web/src/locales/zh/translation.json index cd43454..1ad5e8f 100644 --- a/web/src/locales/zh/translation.json +++ b/web/src/locales/zh/translation.json @@ -22,6 +22,7 @@ }, "AddFromLink": "添加种子", "AddNewTorrent": "添加新种子", + "All": "全部", "ApiDocs": "API 文档", "B": "B", "bps": "bps", @@ -30,13 +31,6 @@ "Cache": "缓存", "Cancel": "取消", "Category": "类别", - "CategoryLabel": { - "Movies": "电影", - "Series": "系列", - "Music": "音乐", - "Other": "其他", - "None": "没有任何" - }, "Clear": "清除", "Close": "关闭", "CloseServer?": "你想关闭服务器吗?", @@ -75,12 +69,16 @@ "Links": "链接", "MB": "MB", "Mbps": "Mbps", + "Movies": "电影", + "Music": "音乐", "Name": "名称", "NasReleases": "NAS 版本", + "None": "没有任何", "NoTorrentsAdded": "没有添加种子", "Offline": "离线", "OK": "确定", "OpenLink": "打开链接", + "Other": "其他", "Peers": "Peers·Seeds", "PiecesCount": "块数量", "PiecesLength": "块长度", @@ -107,6 +105,7 @@ "Sec": "秒", "Seconds": "秒", "SelectSeason": "选择季", + "Series": "系列", "SettingsDialog": { "AddRetrackers": "添加retrackers", "AdditionalSettings": "附加设置",