odootranslationmultilingualpopoedit

How to keep translations separated where the same word is used in English but a different one in other languages?


Imagine I have a report, a letter actually, which I need to translate to several languages. I have created a greeting field in the form which is filled programatically by an onchange event method.

if self.partner_id.gender == 'female':
    self.letter_greeting = _('Dear %s %s,') % (         # the translation should be "Estimada"
        self.repr_recipient_id.title.shorcut, surname
    )
elif self.partner_id.gender == 'male':
    self.letter_greeting = _('Dear %s %s,') % (         # translation "Estimado"
        self.repr_recipient_id.title.shorcut, surname
    )
else:
    self.letter_greeting = _('Dear %s %s,') % (         # translation: "Estimado/a"
        self.partner_id.title.shorcut, surname
    )

In that case the word Dear should be translated to different Spanish translations depending on which option is used, this is because we use different termination depending on the gender. Exporting the po file I found that all the options are altogether, that make sense because almost all the cases the translations will be the same, but not in this case:

#. module: custom_module
#: code:addons/custom_module/models/sale_order.py:334
#: code:addons/custom_module/models/sale_order.py:338
#: code:addons/custom_module/models/sale_order.py:342
#, python-format
msgid "Dear %s %s,"
msgstr "Dear %s %s,"

Solutions I can apply directly

#. module: stock
#: model:res.company,msg:stock.res_company
msgid "Dear"
msgstr "Estimado/a"

This is just an example. I can think of many words that look the same in English, but they use different spelling or meanings in other languages depending on the context.

Possible best solutions

Do you think that I am giving to it too much importance haha? Do you know if there is any better solution? Why is poedit not taking into account that problem at all?


Solution

  • I propose an extension of models res.partner.title and res.partner.

    res.partner.title should get a translateable field for saving salutation prefixes like 'Dear' or 'Sehr geehrter' (German). Maybe it's worth to get something about genders, too, but i won't get into detail here about that. You probably want to show the configuring user an example like "Dear Mr. Name" or something like that. A computed field should work.

    On res.partner you should just implement either a computed field or just a method to get a full salutation for a partner record.