better i18n for "how much" column

fix #600
It also removes the "Amount in …" column by adding information as a
tooltip if necessary
This commit is contained in:
Adrien CLERC 2020-05-02 22:16:33 +02:00
parent 2e3c70edcd
commit b4ee527ed5

View file

@ -1,5 +1,10 @@
{% extends "sidebar_table_layout.html" %} {% extends "sidebar_table_layout.html" %}
{%- macro bill_amount(bill, currency=bill.original_currency, amount=bill.amount) %}
{# Undocumented currencyformat filter from flask_babel is forwarding to Babel format_currency #}
{{ amount|currencyformat(currency if currency != 'XXX' else '') }} ({{ _("%(amount)s each", amount=bill.pay_each_default(amount)|currencyformat(currency if currency != 'XXX' else '')) }})
{% endmacro -%}
{% block title %} - {{ g.project.name }}{% endblock %} {% block title %} - {{ g.project.name }}{% endblock %}
{% block js %} {% block js %}
{% if add_bill %} $('#new-bill > a').click(); {% endif %} {% if add_bill %} $('#new-bill > a').click(); {% endif %}
@ -117,11 +122,6 @@
</th><th>{{ _("For what?") }} </th><th>{{ _("For what?") }}
</th><th>{{ _("For whom?") }} </th><th>{{ _("For whom?") }}
</th><th>{{ _("How much?") }} </th><th>{{ _("How much?") }}
{% if g.project.default_currency != "XXX" %}
</th><th>{{ _("Amount in %(currency)s", currency=g.project.default_currency) }}
{%- else -%}
</th><th>{{ _("Amount") }}
{% endif %}
</th><th>{{ _("Actions") }}</th></tr> </th><th>{{ _("Actions") }}</th></tr>
</thead> </thead>
<tbody> <tbody>
@ -143,13 +143,11 @@
{{ bill.owers|join(', ', 'name') }} {{ bill.owers|join(', ', 'name') }}
{%- endif %}</td> {%- endif %}</td>
<td> <td>
{% if bill.original_currency != "XXX" %} <span data-toggle="tooltip" data-placement="top"
{{ "%0.2f"|format(bill.amount) }} {{bill.original_currency}} ({{ "%0.2f"|format(bill.pay_each_default(bill.amount)) }} {{bill.original_currency}} {{ _(" each") }}) title="{{ bill_amount(bill, g.project.default_currency, bill.converted_amount) if bill.original_currency != g.project.default_currency else '' }}">
{%- else -%} {{ bill_amount(bill) }}
{{ "%0.2f"|format(bill.amount) }} ({{ "%0.2f"|format(bill.pay_each_default(bill.amount)) }} {{ _(" each") }}) </span>
{% endif %}
</td> </td>
<td>{{ "%0.2f"|format(bill.converted_amount) }}</td>
<td class="bill-actions"> <td class="bill-actions">
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a> <a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a>
<a class="delete" href="{{ url_for(".delete_bill", bill_id=bill.id) }}" title="{{ _("delete") }}">{{ _('delete') }}</a> <a class="delete" href="{{ url_for(".delete_bill", bill_id=bill.id) }}" title="{{ _("delete") }}">{{ _('delete') }}</a>