Univention Bugzilla – Bug 40339
Univention Management Console - simplify localization by using named arguments in msgs
Last modified: 2016-02-04 14:04:13 CET
Created attachment 7385 [details] Errors from univention-ucs-translation-build-package.py UCS4.1 +++ This bug was initially created as a clone of Bug #38155 +++ UCS 4.1-0 errata44 == The issue I had multiple warning on UMC files that use msgs syntax with unnamed arguments (eg: %s). Standardizing the use to named arguments like: %(variableName)s will easy the translation to new languages. * Message: <Source-file.py:line> warning: 'msgid' format string with unnamed arguments cannot be properly localized. ---- umc/python/diagnostic/plugins/nameserver.py:43: warning: 'msgid' format string with unnamed arguments cannot be properly localized: The translator cannot reorder the arguments. Please consider using a format string with named arguments, and a mapping instead of a tuple for the arguments. ---- See attachment for all files with those warnings == Fix * The first warning can be solved by using named arguments (see example below). The recommendation is to use %(varname)s format instead of %s. (See link [1]) For example to get rid of the warning for nameserver.py:43, we need to replace this line: msgs = ['\n', _('The nameserver %s (UCR variable %r) is not responsive:') % (ucr[nameserver], nameserver)] For this one: msgs = ['\n', _('The nameserver %(ucr[nameserver])s (UCR variable %(nameserver)r) is not responsive:') % (ucr[nameserver], nameserver)] [1] https://code.djangoproject.com/ticket/3410#comment:5
Rewrote all format strings with multiple arguments in all UMC modules. univention-quota (10.0.1-2): r66794 | Bug #40339: format string with multiple unnamed arguments r66787 | Bug #40339: fix PO metadata univention-system-setup (9.0.2-27): r66793 | Bug #40339: format string with multiple unnamed arguments r66787 | Bug #40339: fix PO metadata univention-appcenter.yaml: r66796 | YAML Bug #40339 univention-management-console.yaml: r66796 | YAML Bug #40339 univention-join.yaml: r66796 | YAML Bug #40339 univention-management-console-module-top.yaml: r66796 | YAML Bug #40339 univention-appcenter (5.0.19-42): r66789 | Bug #40339: format string with multiple unnamed arguments r66787 | Bug #40339: fix PO metadata univention-quota.yaml: r66796 | YAML Bug #40339 univention-management-console-module-adtakeover.yaml: r66796 | YAML Bug #40339
And fixed the last occurrences. No errors anymore against UCS 4.1. univention-management-console (8.0.28-5): r66841 | Bug #40339: fix format string with multiple unnamed arguments univention-directory-manager-modules (11.0.2-13): r66843 | Bug #40339: fix format string with multiple unnamed arguments univention-management-console-frontend (5.0.63-11): r66842 | Bug #40339: fix format string with multiple unnamed arguments r66844 | Bug #40339: fixup r66845 | YAML Bug #40339
OK: checked that modifications in PO files are reflected in js/py code OK: ran some modules (random sample) to check functionality at runtime OK: searched complete 4.1 source code (not just UMC) for format strings with multiple unnamed arguments: ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.po' -exec egrep '_\(.*%.*%\w' {} + ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.js' -exec egrep '_\(.*%.*%\w' {} + ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.py' -exec egrep '_\(.*%.*%\w' {} + ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.po' -exec egrep '%s.*%s' {} + ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.py' -exec egrep '_\(.*%s.*%s' {} + ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.js' -exec egrep '_\(.*%s.*%s' {} + OK: checked output of univention-ucs-translation-build-package: root@ucs26:~# cd ~/sync/ucs-4.1-0 root@ucs26:~/sync/ucs-4.1-0# svn up Password: Revision 66985. root@ucs26:~/sync/ucs-4.1-0# univention-ucs-translation-build-package.py -s ~/sync/ucs-4.1-0 -c de_DE -l de_DE.UTF-8:UTF-8 -n "Deutsch" 2>&1 | grep unnamed [keine Ausgabe]
PS: * typo, must be: >> ~/svn/dev/branches/ucs-4.1/ucs-4.1-0$ find -name '*.po' -exec egrep '.*%.*%\w' {} + <<, but doesn't reveal problems (only in unused translations) * OK: advisories
<http://errata.software-univention.de/ucs/4.1/64.html> <http://errata.software-univention.de/ucs/4.1/66.html> <http://errata.software-univention.de/ucs/4.1/68.html>
<http://errata.software-univention.de/ucs/4.1/79.html> <http://errata.software-univention.de/ucs/4.1/88.html> <http://errata.software-univention.de/ucs/4.1/89.html> <http://errata.software-univention.de/ucs/4.1/90.html> <http://errata.software-univention.de/ucs/4.1/91.html> <http://errata.software-univention.de/ucs/4.1/94.html> <http://errata.software-univention.de/ucs/4.1/97.html>