I encountered a weird behavior from django trans tag. As you know whenever we use a filter inside a tag, the filter first applies and then gives the result as input to the tag. But this is in reverse order for trans tag.
Example:
Suppose I have this django.po file:
msgid "msgid-world"
msgstr "world"
msgid "msgid-"
msgstr "message"
Now see the result of these tags:
{% trans "msgid-"|add:"world" %}
result: messageworld (first translate then concat)
Expected result: "world" (first concat then translate the key)
UPDATE:
My problem is about consistency. The behavior with other tags (like "if") is converse!
Moreover if I write a custom tag for myself like below:
@register.simple_tag
def customtrans(a):
return _(str(a))
then it will behave like other tags. The result of this example (like the above example):
{% customtrans "msgid-"|add:"world" %}
will be "world".
This is the mysterious point I want to understand!