From 7a0a901c2baf921fe8beb2c2e63675255c5c0b35 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 17 Apr 2021 23:28:10 +0200 Subject: [PATCH 1/9] translations fo true/false yes /no --- InvenTree/templates/js/bom.js | 4 ++++ InvenTree/templates/yesnolabel.html | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index beb4110df6..5b62955499 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -268,6 +268,10 @@ function loadBomTable(table, options) { field: 'optional', title: '{% trans "Optional" %}', searchable: false, + formatter: function(value) { + if (value == '1') return '{% trans "true" %}'; + if (value == '0') return '{% trans "false" %}'; + } }); cols.push({ diff --git a/InvenTree/templates/yesnolabel.html b/InvenTree/templates/yesnolabel.html index cdc6070560..2117d42faa 100644 --- a/InvenTree/templates/yesnolabel.html +++ b/InvenTree/templates/yesnolabel.html @@ -1,5 +1,7 @@ +{% load i18n %} + {% if value %} -Yes +{% trans 'Yes' %} {% else %} -No +{% trans 'No' %} {% endif %} \ No newline at end of file From 20af4c9ba0d7675ee0675c3a04a24d06b5344f39 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 17 Apr 2021 23:48:47 +0200 Subject: [PATCH 2/9] template tag for translatable alerts with links --- InvenTree/build/templates/build/build_base.html | 7 +++++-- InvenTree/part/templates/part/part_base.html | 3 ++- InvenTree/part/templatetags/inventree_extras.py | 10 ++++++++++ InvenTree/stock/templates/stock/item_base.html | 8 ++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index a8e5e53377..9da515c2f6 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -3,6 +3,7 @@ {% load static %} {% load i18n %} {% load status_codes %} +{% load inventree_extras %} {% block page_title %} InvenTree | {% trans "Build Order" %} - {{ build }} @@ -11,12 +12,14 @@ InvenTree | {% trans "Build Order" %} - {{ build }} {% block pre_content %} {% if build.sales_order %}
- {% trans "This Build Order is allocated to Sales Order" %} {{ build.sales_order }} + {% object_link 'so-detail' build.sales_order.id build.sales_order as link %} + {% blocktrans %}This Build Order is allocated to Sales Order {{ link }}{% endblocktrans %}
{% endif %} {% if build.parent %}
- {% trans "This Build Order is a child of Build Order" %} {{ build.parent }} + {% object_link 'build-detail' build.parent.id build.parent as link %} + {% blocktrans %}This Build Order is a child of Build Order {{ link }}{% endblocktrans %}
{% endif %} {% endblock %} diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index f11fe879ce..a0a058fa3f 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -14,7 +14,8 @@ {% if part.variant_of %}
- {% trans "This part is a variant of" %} {{ part.variant_of.full_name }} + {% object_link 'part-variants' part.variant_of.id part.variant_of.full_name as link %} + {% blocktrans %}This part is a variant of {{ link }}{% endblocktrans %}
{% endif %} diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index c0dc15c2b0..8366b37f23 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -4,6 +4,8 @@ over and above the built-in Django tags. import os from django import template +from django.urls import reverse +from django.utils.safestring import mark_safe from InvenTree import version, settings import InvenTree.helpers @@ -164,3 +166,11 @@ def authorized_owners(group): pass return owners + + +@register.simple_tag() +def object_link(url_name, pk, ref): + """ Return highlighted link to object """ + + ref_url = reverse(url_name, kwargs={'pk': pk}) + return mark_safe('{}'.format(ref_url, ref)) diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index b955acda9c..23397c9886 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -48,13 +48,17 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% for allocation in item.sales_order_allocations.all %}
- {% trans "This stock item is allocated to Sales Order" %} #{{ allocation.line.order }} ({% trans "Quantity" %}: {% decimal allocation.quantity %}) + {% object_link 'so-detail' allocation.line.order.id allocation.line.order as link %} + {% define decimal allocation.quantity as qty %} + {% blocktrans %}This stock item is allocated to Sales Order {{ link }} (Quantity: {{ qty }}){% endblocktrans %}
{% endfor %} {% for allocation in item.allocations.all %}
- {% trans "This stock item is allocated to Build" %} #{{ allocation.build }} ({% trans "Quantity" %}: {% decimal allocation.quantity %}) + {% object_link 'build-detail' allocation.build.id allocation.build %} + {% define decimal allocation.quantity as qty %} + {% blocktrans %}This stock item is allocated to Build {{ link }} (Quantity: {{ qty }}){% endblocktrans %}
{% endfor %} From 59063bee6b82fca334416df566ea897f8cb5ff67 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 17 Apr 2021 23:52:21 +0200 Subject: [PATCH 3/9] extending translations to the whole sentence --- InvenTree/build/templates/build/build_base.html | 2 +- .../build/templates/build/create_build_item.html | 6 ++---- .../templates/company/manufacturer_part_delete.html | 3 +-- .../templates/order/order_wizard/select_parts.html | 2 +- .../templates/order/order_wizard/select_pos.html | 4 ++-- InvenTree/order/templates/order/receive_parts.html | 2 +- InvenTree/part/templates/part/category_delete.html | 6 +++--- InvenTree/part/templates/part/copy_part.html | 2 +- InvenTree/part/templates/part/create_part.html | 3 ++- InvenTree/part/templates/part/part_pricing.html | 3 +-- InvenTree/part/templates/part/partial_delete.html | 12 ++++++------ InvenTree/part/templates/part/stock.html | 2 +- InvenTree/part/templates/part/variant_part.html | 2 +- InvenTree/stock/templates/stock/item_base.html | 4 ++-- .../stock/templates/stock/stockitem_convert.html | 4 ++-- 15 files changed, 27 insertions(+), 30 deletions(-) diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index 9da515c2f6..d0e68cac4c 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -108,7 +108,7 @@ src="{% static 'img/blank_image.png' %}" {{ build.target_date }} {% if build.is_overdue %} - {% trans "Overdue" %} + {% trans "Overdue" %} {% endif %} diff --git a/InvenTree/build/templates/build/create_build_item.html b/InvenTree/build/templates/build/create_build_item.html index 8f58e884d6..1a7934b88b 100644 --- a/InvenTree/build/templates/build/create_build_item.html +++ b/InvenTree/build/templates/build/create_build_item.html @@ -8,15 +8,13 @@

{% if output %}

- {% trans "The allocated stock will be installed into the following build output:" %} -
- {{ output }} + {% blocktrans %}The allocated stock will be installed into the following build output:
{{ output }}{% endblocktrans %}

{% endif %} {% if no_stock %} {% endif %} {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/manufacturer_part_delete.html b/InvenTree/company/templates/company/manufacturer_part_delete.html index 4d5c2f6c86..98b55934d0 100644 --- a/InvenTree/company/templates/company/manufacturer_part_delete.html +++ b/InvenTree/company/templates/company/manufacturer_part_delete.html @@ -33,8 +33,7 @@ {% if part.supplier_parts.all|length > 0 %}
-

There are {{ part.supplier_parts.all|length }} suppliers defined for this manufacturer part. If you delete it, the following supplier parts will also be deleted: -

+

{% blocktrans %}There are {{ part.supplier_parts.all|length }} suppliers defined for this manufacturer part. If you delete it, the following supplier parts will also be deleted:{% endblocktrans %}

    {% for spart in part.supplier_parts.all %}
  • {{ spart.supplier.name }} - {{ spart.SKU }}
  • diff --git a/InvenTree/order/templates/order/order_wizard/select_parts.html b/InvenTree/order/templates/order/order_wizard/select_parts.html index d3f1796dce..04b3d60a2d 100644 --- a/InvenTree/order/templates/order/order_wizard/select_parts.html +++ b/InvenTree/order/templates/order/order_wizard/select_parts.html @@ -54,7 +54,7 @@
{% if not part.order_supplier %} - {% trans "Select a supplier for" %} {{ part.name }} + {% blocktrans %}Select a supplier for {{ part.name }}{% endblocktrans %} {% endif %} diff --git a/InvenTree/order/templates/order/order_wizard/select_pos.html b/InvenTree/order/templates/order/order_wizard/select_pos.html index 616e618deb..1152736c89 100644 --- a/InvenTree/order/templates/order/order_wizard/select_pos.html +++ b/InvenTree/order/templates/order/order_wizard/select_pos.html @@ -42,7 +42,7 @@