[Solved]-Gender problem in a django i18n translation


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.


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 %}


While waiting for contexts to be supported, an easy alternative would be to slightly change the Spanish sentence and use a greeting that does not vary according to a person’s gender. For example, you could use “hola”, or some other equivalent term.

Leave a comment