mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 19:11:09 +00:00
Merge pull request #1983 from bookwyrm-social/shelf-name-translation
Shelf name translation
This commit is contained in:
commit
6c17aa7630
4 changed files with 26 additions and 13 deletions
|
@ -71,7 +71,9 @@
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ book.id }}">
|
||||||
<input type="hidden" name="shelf" value="{{ user_shelf.id }}">
|
<input type="hidden" name="shelf" value="{{ user_shelf.id }}">
|
||||||
<button class="button is-fullwidth is-small is-radiusless is-danger is-light" type="submit">{% trans "Remove from" %} {{ user_shelf.name }}</button>
|
<button class="button is-fullwidth is-small is-radiusless is-danger is-light" type="submit">
|
||||||
|
{% blocktrans with name=user_shelf|translate_shelf_name %}Remove from {{ name }}{% endblocktrans %}
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||||
<input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
|
<input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
|
||||||
<button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">
|
<button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">
|
||||||
{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}
|
{% blocktrans with name=active_shelf.shelf|translate_shelf_name %}Remove from {{ name }}{% endblocktrans %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -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,24 @@ 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 ""
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
@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