diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html index eb6c620..69e45e0 100644 --- a/accounting/templates/accounting/cash.html +++ b/accounting/templates/accounting/cash.html @@ -24,7 +24,8 @@ First written: 2020/7/1 {% load humanize %} {% block settings %} - {% trans "Cash Report" context "Accounting|" as title %} + {% trans "Cash Account for {} in {}" context "Accounting|" as title_format %} + {% format title_format "庫存現金" period_parser.description as title %} {% setvar "title" title %} {% endblock %} diff --git a/mia_core/templatetags.py b/mia_core/templatetags.py index 1580090..b357354 100644 --- a/mia_core/templatetags.py +++ b/mia_core/templatetags.py @@ -30,3 +30,19 @@ def setvar(context, key, value): """ context.dicts[0][key] = value return "" + + +@register.simple_tag(takes_context=True) +def format(context, format, *args, **kwargs): + """Sets a variable in the template. + + Args: + context (Context): the context. + format (str): The format. + args (str): The parameters. + kwargs (str): The keyword arguments. + """ + if "as" in kwargs: + context.dicts[0][kwargs["as"]] = format.format(*args) + return "" + return format.format(*args)