mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21: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 %}
|
{% load i18n %}
|
||||||
{% if shelf.identifier == 'all' %}
|
{% load shelf_tags %}
|
||||||
{% trans "All books" %}
|
|
||||||
{% elif shelf.identifier == 'to-read' %}
|
{{ shelf|translate_shelf_name }}
|
||||||
{% trans "To Read" %}
|
|
||||||
{% elif shelf.identifier == 'reading' %}
|
|
||||||
{% trans "Currently Reading" %}
|
|
||||||
{% elif shelf.identifier == 'read' %}
|
|
||||||
{% trans "Read" %}
|
|
||||||
{% else %}
|
|
||||||
{{ shelf.name }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
""" Filters and tags related to shelving books """
|
""" Filters and tags related to shelving books """
|
||||||
from django import template
|
from django import template
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm.utils import cache
|
from bookwyrm.utils import cache
|
||||||
|
@ -32,6 +33,23 @@ def get_next_shelf(current_shelf):
|
||||||
return "to-read"
|
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)
|
@register.simple_tag(takes_context=True)
|
||||||
def active_shelf(context, book):
|
def active_shelf(context, book):
|
||||||
"""check what shelf a user has a book on, if any"""
|
"""check what shelf a user has a book on, if any"""
|
||||||
|
|
Loading…
Reference in a new issue