I need to solve a gender translation problem, and Django doesn't seem to have gettext contexts implemented yet...
I need to translate from english:
<p>Welcome, {{ username }}</p>
In two forms of spanish, one for each gender. If user is a male:
<p>Bienvenido, {{ username }}</p>
and if is a female:
<p>Bienvenida, {{ username }}</p>
note the difference (bienvenido/bienvenida)
Is there any way of getting this done?
Thanks,
H.
The way that I've solved this is:
{% if profile.male %}
{% blocktrans with profile.name as male %}Welcome, {{ male }}{% endblocktrans %}
{% else %}
{% blocktrans with profile.name as female %}Welcome, {{ female }}{% endblocktrans %}
{% endif %}
Django is just Python so you can use the Python gettext bindings directly if you need to, I don't see any reason you couldn't write a {% gender_trans [gender] %} tag.
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