diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index 1fb799883..ea093b8a5 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -9,6 +9,14 @@ from bookwyrm.utils import cache register = template.Library() +SHELF_NAMES = { + "all": _("All books"), + "to-read": _("To Read"), + "reading": _("Currently Reading"), + "read": _("Read"), +} + + @register.filter(name="is_book_on_shelf") def get_is_book_on_shelf(book, shelf): """is a book on a shelf""" @@ -42,15 +50,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)