The following code is not working
from django.utils.translation import gettext_lazy as _
stringtest=_("First string")
stringtest= stringtest + _(" Second string")
print stringtest
I get the following exception:
cannot concatenate 'str' and '__proxy__' objects
Is it really impossible to append a "translated" string to himself ?
We can use format_lazy.
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _
msgs_to_concat = [_("First string"), _(" Second string")]
stringtest = format_lazy('{}'*len(msgs_to_concat), *msgs_to_concat)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With