Skip to content

Commit

Permalink
add categories feature translation #26
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Nov 4, 2023
1 parent d1e9e72 commit ff565ac
Show file tree
Hide file tree
Showing 23 changed files with 894 additions and 31 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public function getFilters()
'urlToMarkdown'
]
),
new TwigFilter(
'trans_category',
[
$this,
'transCategory'
]
),
];
}

Expand Down Expand Up @@ -153,6 +160,29 @@ public function urlToMarkdown(
);
}

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];
Expand Down
2 changes: 1 addition & 1 deletion templates/default/torrent/edit/categories.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" />
{% endif %}
<label class="margin-l-4-px" for="{{ category }}">
{{ category | u.title }}
{{ category | trans_category | u.title }}
</label>
</div>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/default/torrent/info.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
{% if torrent.categories %}
<div class="padding-y-4-px">
{% set i = 0 %}
{% for category in torrent.categories | sort %}{% if i > 0 %},{% endif %} {{ category | u.title }}{% set i = i + 1 %}{% endfor %}
{% for category in torrent.categories | sort %}{% if i > 0 %},{% endif %} {{ category | trans_category | u.title }}{% set i = i + 1 %}{% endfor %}
</div>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/default/torrent/submit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" />
{% endif %}
<label class="margin-l-4-px" for="{{ category }}">
{{ category | u.title }}
{{ category | trans_category | u.title }}
</label>
</div>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/default/user/info.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
</td>
<td class="width-80 line-height-20-px">
{% set i = 0 %}
{% for category in user.categories | sort %}{% if i > 0 %},{% endif %} {{ category | u.title }}{% set i = i + 1 %}{% endfor %}
{% for category in user.categories | sort %}{% if i > 0 %},{% endif %} {{ category | trans_category | u.title }}{% set i = i + 1 %}{% endfor %}
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion templates/default/user/settings.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<input name="categories[]" id="{{ category }}" type="checkbox" value="{{ category }}" />
{% endif %}
<label class="margin-x-4-px" for="{{ category }}">
{{ category | u.title | trans }}
{{ category | trans_category | u.title }}
</label>
</div>
{% endfor %}
Expand Down
52 changes: 52 additions & 0 deletions translations/messages+intl-icu.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,58 @@
<source>have added categories edition</source>
<target>have added categories edition</target>
</trans-unit>
<trans-unit id="imujLJv" resname="movie">
<source>movie</source>
<target>movie</target>
</trans-unit>
<trans-unit id="nNo46jo" resname="series">
<source>series</source>
<target>series</target>
</trans-unit>
<trans-unit id="pG5dK74" resname="tv">
<source>tv</source>
<target>tv</target>
</trans-unit>
<trans-unit id="7CPO8DE" resname="animation">
<source>animation</source>
<target>animation</target>
</trans-unit>
<trans-unit id="gPGJmE5" resname="music">
<source>music</source>
<target>music</target>
</trans-unit>
<trans-unit id="bKXKt35" resname="game">
<source>game</source>
<target>game</target>
</trans-unit>
<trans-unit id="PYW9Udx" resname="audiobook">
<source>audiobook</source>
<target>audiobook</target>
</trans-unit>
<trans-unit id="9ippfeB" resname="podcast">
<source>podcast</source>
<target>podcast</target>
</trans-unit>
<trans-unit id="knGf4M_" resname="book">
<source>book</source>
<target>book</target>
</trans-unit>
<trans-unit id="DrPja.s" resname="archive">
<source>archive</source>
<target>archive</target>
</trans-unit>
<trans-unit id="LOonTQv" resname="picture">
<source>picture</source>
<target>picture</target>
</trans-unit>
<trans-unit id="NTkPVFP" resname="software">
<source>software</source>
<target>software</target>
</trans-unit>
<trans-unit id="2SmKENG" resname="other">
<source>other</source>
<target>other</target>
</trans-unit>
</body>
</file>
</xliff>
52 changes: 52 additions & 0 deletions translations/messages+intl-icu.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,58 @@
<source>have added categories edition</source>
<target>have added categories edition</target>
</trans-unit>
<trans-unit id="imujLJv" resname="movie">
<source>movie</source>
<target>movie</target>
</trans-unit>
<trans-unit id="nNo46jo" resname="series">
<source>series</source>
<target>series</target>
</trans-unit>
<trans-unit id="pG5dK74" resname="tv">
<source>tv</source>
<target>tv</target>
</trans-unit>
<trans-unit id="7CPO8DE" resname="animation">
<source>animation</source>
<target>animation</target>
</trans-unit>
<trans-unit id="gPGJmE5" resname="music">
<source>music</source>
<target>music</target>
</trans-unit>
<trans-unit id="bKXKt35" resname="game">
<source>game</source>
<target>game</target>
</trans-unit>
<trans-unit id="PYW9Udx" resname="audiobook">
<source>audiobook</source>
<target>audiobook</target>
</trans-unit>
<trans-unit id="9ippfeB" resname="podcast">
<source>podcast</source>
<target>podcast</target>
</trans-unit>
<trans-unit id="knGf4M_" resname="book">
<source>book</source>
<target>book</target>
</trans-unit>
<trans-unit id="DrPja.s" resname="archive">
<source>archive</source>
<target>archive</target>
</trans-unit>
<trans-unit id="LOonTQv" resname="picture">
<source>picture</source>
<target>picture</target>
</trans-unit>
<trans-unit id="NTkPVFP" resname="software">
<source>software</source>
<target>software</target>
</trans-unit>
<trans-unit id="2SmKENG" resname="other">
<source>other</source>
<target>other</target>
</trans-unit>
</body>
</file>
</xliff>
52 changes: 52 additions & 0 deletions translations/messages+intl-icu.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,58 @@
<source>have added categories edition</source>
<target>have added categories edition</target>
</trans-unit>
<trans-unit id="imujLJv" resname="movie">
<source>movie</source>
<target>movie</target>
</trans-unit>
<trans-unit id="nNo46jo" resname="series">
<source>series</source>
<target>series</target>
</trans-unit>
<trans-unit id="pG5dK74" resname="tv">
<source>tv</source>
<target>tv</target>
</trans-unit>
<trans-unit id="7CPO8DE" resname="animation">
<source>animation</source>
<target>animation</target>
</trans-unit>
<trans-unit id="gPGJmE5" resname="music">
<source>music</source>
<target>music</target>
</trans-unit>
<trans-unit id="bKXKt35" resname="game">
<source>game</source>
<target>game</target>
</trans-unit>
<trans-unit id="PYW9Udx" resname="audiobook">
<source>audiobook</source>
<target>audiobook</target>
</trans-unit>
<trans-unit id="9ippfeB" resname="podcast">
<source>podcast</source>
<target>podcast</target>
</trans-unit>
<trans-unit id="knGf4M_" resname="book">
<source>book</source>
<target>book</target>
</trans-unit>
<trans-unit id="DrPja.s" resname="archive">
<source>archive</source>
<target>archive</target>
</trans-unit>
<trans-unit id="LOonTQv" resname="picture">
<source>picture</source>
<target>picture</target>
</trans-unit>
<trans-unit id="NTkPVFP" resname="software">
<source>software</source>
<target>software</target>
</trans-unit>
<trans-unit id="2SmKENG" resname="other">
<source>other</source>
<target>other</target>
</trans-unit>
</body>
</file>
</xliff>
52 changes: 52 additions & 0 deletions translations/messages+intl-icu.eo.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,58 @@
<source>have added categories edition</source>
<target>have added categories edition</target>
</trans-unit>
<trans-unit id="imujLJv" resname="movie">
<source>movie</source>
<target>movie</target>
</trans-unit>
<trans-unit id="nNo46jo" resname="series">
<source>series</source>
<target>series</target>
</trans-unit>
<trans-unit id="pG5dK74" resname="tv">
<source>tv</source>
<target>tv</target>
</trans-unit>
<trans-unit id="7CPO8DE" resname="animation">
<source>animation</source>
<target>animation</target>
</trans-unit>
<trans-unit id="gPGJmE5" resname="music">
<source>music</source>
<target>music</target>
</trans-unit>
<trans-unit id="bKXKt35" resname="game">
<source>game</source>
<target>game</target>
</trans-unit>
<trans-unit id="PYW9Udx" resname="audiobook">
<source>audiobook</source>
<target>audiobook</target>
</trans-unit>
<trans-unit id="9ippfeB" resname="podcast">
<source>podcast</source>
<target>podcast</target>
</trans-unit>
<trans-unit id="knGf4M_" resname="book">
<source>book</source>
<target>book</target>
</trans-unit>
<trans-unit id="DrPja.s" resname="archive">
<source>archive</source>
<target>archive</target>
</trans-unit>
<trans-unit id="LOonTQv" resname="picture">
<source>picture</source>
<target>picture</target>
</trans-unit>
<trans-unit id="NTkPVFP" resname="software">
<source>software</source>
<target>software</target>
</trans-unit>
<trans-unit id="2SmKENG" resname="other">
<source>other</source>
<target>other</target>
</trans-unit>
</body>
</file>
</xliff>
52 changes: 52 additions & 0 deletions translations/messages+intl-icu.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,58 @@
<source>have added categories edition</source>
<target>have added categories edition</target>
</trans-unit>
<trans-unit id="imujLJv" resname="movie">
<source>movie</source>
<target>movie</target>
</trans-unit>
<trans-unit id="nNo46jo" resname="series">
<source>series</source>
<target>series</target>
</trans-unit>
<trans-unit id="pG5dK74" resname="tv">
<source>tv</source>
<target>tv</target>
</trans-unit>
<trans-unit id="7CPO8DE" resname="animation">
<source>animation</source>
<target>animation</target>
</trans-unit>
<trans-unit id="gPGJmE5" resname="music">
<source>music</source>
<target>music</target>
</trans-unit>
<trans-unit id="bKXKt35" resname="game">
<source>game</source>
<target>game</target>
</trans-unit>
<trans-unit id="PYW9Udx" resname="audiobook">
<source>audiobook</source>
<target>audiobook</target>
</trans-unit>
<trans-unit id="9ippfeB" resname="podcast">
<source>podcast</source>
<target>podcast</target>
</trans-unit>
<trans-unit id="knGf4M_" resname="book">
<source>book</source>
<target>book</target>
</trans-unit>
<trans-unit id="DrPja.s" resname="archive">
<source>archive</source>
<target>archive</target>
</trans-unit>
<trans-unit id="LOonTQv" resname="picture">
<source>picture</source>
<target>picture</target>
</trans-unit>
<trans-unit id="NTkPVFP" resname="software">
<source>software</source>
<target>software</target>
</trans-unit>
<trans-unit id="2SmKENG" resname="other">
<source>other</source>
<target>other</target>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit ff565ac

Please sign in to comment.