Hi,
On 02.03.2017 19:43, Uri Even-Chen wrote:
What if we "cheat" makemessages like this:
{% if 0%}{% trans 'This user blocked you.' context 'female' %} {%
trans 'This user blocked you.' context 'male' %} {% trans 'This user
blocked you.' context 'other' %} {% endif %}
{%trans 'This user blocked you.' context user.gender %}
(or maybe we should filter user.gender with a filter that returns
"female", "male" or "other" (because they are integers).
It looks better to me and less work to "cheat" makemessages like this,
unless there is a better solution? Because translations which don't
exist in the code will be commented every time we run makemessages.
Maybe this is a feature we can add to the next Django release? And
then we will not have to "cheat"?
This will be really problematic.
First, how makemessage command would know all the possible values of
"user.gender"? Where that information would be obtained? It must be
available somewhere when processing strings for translations.
If user.gender is fixed list and you know that, you could pick existing
code of makemessages and enhance it with your custom code that magically
knows values for user.gender. So you need to code that part yourself and
it would be special command to your app(s).
Another option that Melvyn suggested is to have totally custom tag that
contains possible values and then variable to choose among them. That
could work just fine, but still you need to do custom makemessages
command that would understand your tag and it's syntax.
Makemessages managemen command code can be found at:
https://github.com/django/django/blob/master/django/core/management/commands/makemessages.py
--
Jani Tiainen
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/0855de33-0ab9-2a01-595a-374674e6a9df%40gmail.com.
For more options, visit https://groups.google.com/d/optout.