On Jul 12, 2010, at 1:32 PM, Álvaro Justen wrote:
> On Mon, Jul 12, 2010 at 17:16, Jonathan Lundell <[email protected]> wrote:
>> On Jul 12, 2010, at 12:51 PM, mdipierro wrote:
>>
>>> suggestions? :-)
>>
>> Ideally (from a usability pov), a variant="something" argument to T(), I
>> suppose. But I can't think of a non-messy way to do it.
>>
>> How about something like this:
>>
>> T('string to translate [[VARIANT something]]')
>> T('string to translate [[VARIANT something else]]')
>>
>> If there's no translation in effect, then [[VARIANT .*?]] *$ gets stripped
>> from the string. Otherwise it's part of the lookup. It could just be
>>
>> [[something]]
>> [[something else]]
>>
>> ...keeping in mind that if you really wanted that at the end of a T()
>> string, you could write:
>>
>> T('blah blah [[blah]][[]]')
>>
>> ...and only the trailing [[]] would be stripped.
>>
>> BTW, there's a typo in languages.py:
>>
>> # patter for a valid accept_language
>>
>> (and the pattern could use a comment or three)
>
> I don't like the idea of changing the string to be translated. We can
> use a 'context' parameter as I said in other email some time ago,
> like:
> T('canto', context='my room') #translating from pt-BR to English
> should be 'corner'
> T('canto', context='music') #translating from pt-BR to English should be
> 'sing'
That is, btw, my 'variant=' suggestion, above. If it's practical, I'd prefer
it. But embedding the variant/context into the string would be (I think) less
disruptive.
T('canto [[my room]]')
T('canto [[music]]')
Not as pretty, but almost identical in effect.