Hi,
I need to translate a string that contains a non-breaking space ("\xa0"), but I can't find a way to translate this string properly. The translation ignores the special character or doesn't translate the string at all. Eventually I came up with this solution:
from django.utils.translation import gettext_lazy as _, pgettext_lazy
return _("On {date} ({timesince} ago)")\
.replace(" ago)", "\xa0ago)")\
.replace("(לפני ", "(לפני\xa0")\
.format(
date=formats.date_format(value=last_visit_date),
timesince=timesince(d=last_visit_date, now=today),
)
Which works, but I would prefer to translate the string properly and not replace the translated string after its translation.
Notice that English returns the original string without any translation.
(I tried to translate the string "On {date} ({timesince}\xa0ago)" but it didn't work)
Any ideas?
Thanks,