diff --git a/.env b/.env index e3d5643..9dac3a8 100644 --- a/.env +++ b/.env @@ -60,6 +60,7 @@ APP_LOCALE=en APP_LOCALES=en|cs|nl|eo|fr|ja|ka|de|he|it|lv|pl|pt|ru|es|uk # Content categories, lowercase, enabled by default for new users +# src/Twig/AppExtension.php:transCategory APP_CATEGORIES=movie|series|tv|animation|music|game|audiobook|podcast|book|archive|picture|software|other # Items per page on pagination diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index c0bbcf4..8da3975 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -46,6 +46,13 @@ class AppExtension extends AbstractExtension 'urlToMarkdown' ] ), + new TwigFilter( + 'trans_category', + [ + $this, + 'transCategory' + ] + ), ]; } @@ -153,6 +160,29 @@ class AppExtension extends AbstractExtension ); } + public function transCategory( + string $name + ): string + { + switch ($name) + { + case 'movie': return $this->translator->trans('movie'); + case 'series': return $this->translator->trans('series'); + case 'tv': return $this->translator->trans('tv'); + case 'animation': return $this->translator->trans('animation'); + case 'music': return $this->translator->trans('music'); + case 'game': return $this->translator->trans('game'); + case 'audiobook': return $this->translator->trans('audiobook'); + case 'podcast': return $this->translator->trans('podcast'); + case 'book': return $this->translator->trans('book'); + case 'archive': return $this->translator->trans('archive'); + case 'picture': return $this->translator->trans('picture'); + case 'software': return $this->translator->trans('software'); + case 'other': return $this->translator->trans('other'); + default: return $name; + } + } + private function plural(int $number, array $texts) { $cases = [2, 0, 1, 1, 1, 2]; diff --git a/templates/default/torrent/edit/categories.html.twig b/templates/default/torrent/edit/categories.html.twig index c094952..417828d 100644 --- a/templates/default/torrent/edit/categories.html.twig +++ b/templates/default/torrent/edit/categories.html.twig @@ -32,7 +32,7 @@ {% endif %} {% endfor %} diff --git a/templates/default/torrent/info.html.twig b/templates/default/torrent/info.html.twig index 10f8721..4d530ab 100644 --- a/templates/default/torrent/info.html.twig +++ b/templates/default/torrent/info.html.twig @@ -362,7 +362,7 @@ {% if torrent.categories %}