riccardoFasan / polyglot

Polyglot is a CLI tool that automates translations tasks. Using the DeepL API, Polyglot generates a translated file from a given source.
https://pypi.org/project/polyglot-translator/
MIT License
15 stars 2 forks source link

When a msgid contains %(keyword)s, keyword should not be translated #6

Open alexis-via opened 1 year ago

alexis-via commented 1 year ago

Thanks for this great tool !

It works well, but I have one problem, to use your lib in real-life PO files from Odoo/OCA modules. My PO file contains:

#: code:addons/l10n_fr_das2/models/l10n_fr_das2.py:0
msgid "Company '%(company)s' is configured in country '%(country)s'."
msgstr ""

When I run:

python -m polyglot translate --from EN --to FR -s filename.po

I get the following result:

#: code:addons/l10n_fr_das2/models/l10n_fr_das2.py:0
msgid "Company '%(company)s' is configured in country '%(country)s'."
msgstr "L'entreprise \"%(entreprise)s\" est configurée dans le pays \"%(pays)s\"."

The keywords 'company' and 'country' should not be translated!

riccardoFasan commented 1 year ago

Hi, thank you for reporting the issue. I will try to make the fix as soon as I have time

riccardoFasan commented 1 year ago

Hi @alexis-via, can you test this PR? I added an argument where you can pass the variable wrapper. in your case you just add -v "'%(" ")s'"