Merge pull request #2789 from bpeel/translatable-shelf-name

Fix two places where the reading status shelf name wasn’t translated
This commit is contained in:
Jascha Ezra Urbach 2023-04-15 16:59:59 +02:00 committed by GitHub
commit fadbc76aaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View file

@ -4,6 +4,7 @@
{% load humanize %}
{% load utilities %}
{% load static %}
{% load shelf_tags %}
{% block title %}{{ book|book_title }}{% endblock %}
@ -245,7 +246,7 @@
<ul>
{% for shelf in user_shelfbooks %}
<li class="box">
<a href="{{ shelf.shelf.local_path }}">{{ shelf.shelf.name }}</a>
<a href="{{ shelf.shelf.local_path }}">{{ shelf.shelf|translate_shelf_name }}</a>
<div class="is-pulled-right">
{% include 'snippets/shelf_selector.html' with shelf=shelf.shelf class="is-small" readthrough=readthrough %}
</div>

View file

@ -9,6 +9,15 @@ from bookwyrm.utils import cache
register = template.Library()
SHELF_NAMES = {
"all": _("All books"),
"to-read": _("To Read"),
"reading": _("Currently Reading"),
"read": _("Read"),
"stopped-reading": _("Stopped Reading"),
}
@register.filter(name="is_book_on_shelf")
def get_is_book_on_shelf(book, shelf):
"""is a book on a shelf"""
@ -42,15 +51,11 @@ def get_translated_shelf_name(shelf):
return ""
# support obj or dict
identifier = shelf["identifier"] if isinstance(shelf, dict) else shelf.identifier
if identifier == "all":
return _("All books")
if identifier == "to-read":
return _("To Read")
if identifier == "reading":
return _("Currently Reading")
if identifier == "read":
return _("Read")
return shelf["name"] if isinstance(shelf, dict) else shelf.name
try:
return SHELF_NAMES[identifier]
except KeyError:
return shelf["name"] if isinstance(shelf, dict) else shelf.name
@register.simple_tag(takes_context=True)