mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Move translations to filter
This commit is contained in:
parent
ab1c7c6d0a
commit
0f5fd6be15
2 changed files with 21 additions and 11 deletions
|
@ -1,12 +1,4 @@
|
|||
{% load i18n %}
|
||||
{% if shelf.identifier == 'all' %}
|
||||
{% trans "All books" %}
|
||||
{% elif shelf.identifier == 'to-read' %}
|
||||
{% trans "To Read" %}
|
||||
{% elif shelf.identifier == 'reading' %}
|
||||
{% trans "Currently Reading" %}
|
||||
{% elif shelf.identifier == 'read' %}
|
||||
{% trans "Read" %}
|
||||
{% else %}
|
||||
{{ shelf.name }}
|
||||
{% endif %}
|
||||
{% load shelf_tags %}
|
||||
|
||||
{{ shelf|translate_shelf_name }}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" Filters and tags related to shelving books """
|
||||
from django import template
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.utils import cache
|
||||
|
@ -32,6 +33,23 @@ def get_next_shelf(current_shelf):
|
|||
return "to-read"
|
||||
|
||||
|
||||
@register.filter(name="translate_shelf_name")
|
||||
def get_translated_shelf_name(shelf):
|
||||
"""produced translated shelf nidentifierame"""
|
||||
if not shelf:
|
||||
return ""
|
||||
identifier = 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
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def active_shelf(context, book):
|
||||
"""check what shelf a user has a book on, if any"""
|
||||
|
|
Loading…
Reference in a new issue