Le 30/04/2014 22:15, Douglas Fish a écrit :
Thinking about the user of contextual markers a bit: If the same string exists with two different contextual markers its going to get put into the PO file twice. Once with each unique contextual marker. Contextual markers won't reduce the amount of stuff that needs to be translated.
Here is a quick way to check if a translation exists without contextual markers: (.venv)yves@paradox ~/openstack/horizon $ python manage.py shell Python 2.7.4 (default, Sep 26 2013, 03:20:26) Type "copyright", "credits" or "license" for more information. IPython 2.0.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: from django.utils.translation import activate, gettext In [2]: activate('fr') In [3]: print gettext('Start') Démarrer (the same can be done with "from django.utils.translation import pgettxt") and use pgettext(context_message, string) to check if a translation exists "with 'context_message'") As you see, in the example above the string is already translated without a context, so we should not add a context to it if we want to keep the existing translation, "unless" it will be used in another context (i.e.: here this word is used to "Start" an instance, but if you use it in a sentence like "Please choose a network to be configured at Start", "Start" in French would be "démarrage" and if it where introduced as a variable in the sentence the existing translation would fail. (Even the word "Démarrer" is wrong "inside" a sentence where it should be "démarrer" (capital letter only at the beginning of a sentence or for Nouns, and "Démarrer" is a verb not a Noun. Even worse: each language has it's own rules when it comes to Nouns, Verbs, etc... so I admit that for the coder it's a situation where he/she can pull his/her hair off to know if a contextual marker is required or not. So as long as a word has no contextual marker and is already translated and also used always in the same context, indeed, it does not need a contextual marker if we do not want to duplicate it in the PO file. But... e.g. in French (and even more in other languages), "Start" can be "Démarrer", "Démarrage", "Début" depending on the context. This context is guessable by the translator if the word is in a full sentence, but in sentences using the word alone as a variable there is no way the translator can guess the context when he sees the word alone. Also, a word alone can generally not be added to an existing string, because for many languages, a word which starts with a capital letter inside a sentence is just wrong if the word is not a Noun. Only a contextual marker allows the translator to know where it is placed. So indeed, you are right saying that adding contextual markers can lead to adding an already existing string. If this string is long or always used in the same context, then the contextual marker is not necessary. However if it's a short word used as a variable inside a string, in many languages without a context it will work in "one" place in the whole code and fail in all the others. If it's a short word not used as a variable in another sentence, and already translated, then we will not add the contextual marker to be able to reuse the existing translation. The difficulty I admit it is to know if a string is already used in the same context with or without a contextual marker. This leads to searching for the string to reuse the same contextual marker if it exists, or to check if it will be used in the same context if it is translated without a contextual marker... I admit it can give some head-aches :-) -- Yves-Gwenaël Bourhis