URL: https://github.com/freeipa/freeipa/pull/1997 Author: stanislavlevin Title: #1997: Fix translation of python brace formatted messages Action: opened
PR body: """ Some of the messages cannot be translated because of a broken python brace formatting.
Simple reproducer:
Take a translatable message string from ipaserver/plugins/topology.py ```Topology management requires minimum domain level {0} ``` and put it on a test script with original formatting: ```python #!/usr/bin/python
import gettext ru = gettext.translation('ipa', languages=['ru'])
ru.install() _ = ru.gettext
test_value = '1' msgtest = _('Topology management requires minimum domain level {0} '.format(test_value))
print(msgtest) ```
Out: ```Topology management requires minimum domain level 1```
But msgid is here, should be no problem: ```msgunfmt /usr/share/locale/ru/LC_MESSAGES/ipa.mo | grep 'Topology management requires minimum domain level {0} ' -A 1 msgid "Topology management requires minimum domain level {0} " msgstr "Управление топологией требует уровня домена не ниже {0}" ```
Cause: The 'format' method should be called after a gettext one to follow 'python-brace-format' rule:
```python msgtest = _('Topology management requires minimum domain level {0} ').format(desired_value) ```
with correct out: ```Управление топологией требует уровня домена не ниже 1```
List of affected: ``` ipaserver/plugins/idrange.py:56 ipaserver/plugins/idrange.py:246 ipaserver/plugins/idrange.py:383 ipaserver/plugins/idrange.py:616 ipaserver/plugins/trust.py:688 ipaserver/plugins/topology.py:88 ipaserver/plugins/topology.py:257 ipaserver/plugins/topology.py:265 ipaserver/plugins/serverroles.py:82 ipaserver/plugins/serverroles.py:167 ipaserver/plugins/domainlevel.py:68 ipaserver/plugins/domainlevel.py:153 ```
This patch should fix it.
"""
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1997/head:pr1997 git checkout pr1997
URL: https://github.com/freeipa/freeipa/pull/1997 Author: stanislavlevin Title: #1997: Fix translation of python brace formatted messages Action: closed
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1997/head:pr1997 git checkout pr1997
freeipa-devel@lists.fedorahosted.org