Univention Bugzilla – Bug 43594
Integrate translations into package build via debian/*.univention-l10n files
Last modified: 2017-06-16 19:16:16 CEST
At several places (e.g., login, setup, activation, portal) we need a way to integrate the translations into the package build. It would be very helpful to have a tool which uses the existing libraries to read debian/*.univention-l10n files and which can be integrated into debian/rules file.
From Bug 38824, comment 10: > There is no de.po anymore in univention-management-console/ for the > javascript files.
Self service translations are missing, cf. Bug 42267, comment 6: > [...] > (f) German translations are missing.
As far as I see, the following packages/package parts are not translated ATM: base/univention-system-setup/var/www/univention/setup/ management/univention-portal/www management/univention-self-service/www management/univention-management-console/www/ management/univention-management-console-module-passwordchange/js/
Revisions r77130 r77131 r77132 r77297 and r77303 extend translationhelper to able to generate all message catalogs per source package. This enables us to use its API to build the integration described in comment #1. Two tools to use with(in) debian/rules are added (univention-l10-build & univention-l10n-install) UCS 4.2: Package: univention-ucs-translation-template Version: 4.2.0-0A~4.2.0.201703022124 Branch: ucs_4.2-0 TODO: changelog entry...
I get a traceback when xgettext returns a non-zero exit code. > usr/share/univention-system-setup-boot/www/de.po:55: Mehrfachdefinition der Meldung... > usr/share/univention-system-setup-boot/www/de.po:25: ...dies ist die Stelle der ersten Definition > xgettext: es ist 1 fataler Fehler aufgetreten >Traceback (most recent call last): > File "/usr/bin/univention-l10n-build", line 56, in <module> > source_file_set.process_po(po_target.new_po_path) > File "/usr/lib/pymodules/python2.7/univention/translationhelper/sourcefileprocessing.py", line 107, in process_po > message_catalogs.join_existing('JavaScript', new_po_path, html_path, cwd=self.src_pkg_path) > File "/usr/lib/pymodules/python2.7/univention/translationhelper/message_catalogs.py", line 87, in join_existing > _call_gettext('xgettext', '--from-code=UTF-8', '--join-existing', '--omit-header', '--language', language, '-o', output_file, *input_files, cwd=cwd) > File "/usr/lib/pymodules/python2.7/univention/translationhelper/message_catalogs.py", line 101, in _call_gettext > raise GettextError("Error: A gettext tool exited unsuccessfully. Attempted command:\n{}".format(exc.cmd)) > univention.translationhelper.message_catalogs.GettextError: Error: A gettext tool exited unsuccessfully. Attempted command: > ['xgettext', '--from-code=UTF-8', '--join-existing', '--omit-header', '--language', 'JavaScript', '-o', u'usr/share/univention-system-setup-boot/www/de.po', 'usr/share/univention-system-setup-boot/www/index.html'] It also seems that (at least for HTML files) new entries are added to the PO file which are empty and which have already been defined in the PO file.
I added handling for a po_path property which allows to directly specify a path for the PO file. BTW, I just realized that you did some commits using an old Bug number (42260). univention-ucs-translation-template (4.2.0-1): r77329 | Bug #42260: allow po_path property
Here an example output for univention-system-setup: > ./usr/share/univention-system-setup-boot/www/i18n/de/main.json > ./usr/share/univention-system-setup-boot/www/i18n/de/main.po > ./usr/share/locale/de/LC_MESSAGES/univention-system-setup-scripts.po > ./usr/share/univention-system-setup/www/i18n/de/main.json > ./usr/share/univention-system-setup/www/de.po > ./debian/univention-system-setup/usr/share/locale/de/LC_MESSAGES/univention-system-setup-scripts.mo I would vote for installing json and mo files directly debian/<packageName>
(In reply to Alexander Kläser from comment #5) > [...] > It also seems that (at least for HTML files) new entries are added to the PO > file which are empty and which have already been defined in the PO file. I fixed this. Besides from that, I realized that obsolete entries of a HTML file are not removed/commented out. univention-ucs-translation-template (4.2.0-2): r77332 | Bug #43594: fix double po entries for HTML files
(In reply to Alexander Kläser from comment #8) > [...] > I fixed this. Besides from that, I realized that obsolete entries of a HTML > file are not removed/commented out. Same applies to JavaScript files. After removing a translation string from the source file, the string is still present in the built po file.
Eduard, please check. I adjusted the process_target() method in order to install the target files below debian/<packageName>. This looked fine in my tests. I actually do not understand why not all classes posses this method. univention-ucs-translation-template (4.2.0-4): r77349 | Bug #43594: make sure to install mo/json files to debian/<packageName>
I observed problems with JavaScript files being detected as HTML files. This happened in package univention-self-service with the file hook/passwordreset.js: > $ file hook/passwordreset.js > hook/passwordreset.js: HTML document, ASCII text Therefore I added in MimeChecker::get() a first test for file suffix. Python magic is then only used if the suffix is unknown. univention-ucs-translation-template (4.2.0-5): r77352 | Bug #43594: fix problems with mime type detection for JavaScript files
(In reply to Alexander Kläser from comment #9) > (In reply to Alexander Kläser from comment #8) > > [...] > > I fixed this. Besides from that, I realized that obsolete entries of a HTML > > file are not removed/commented out. > > Same applies to JavaScript files. After removing a translation string from > the source file, the string is still present in the built po file. If I understand correctly, there seems to be a logic error. The current logic does create PO entries which are merged (via xgettext --join-existing) into the already existing PO file. This PO file is then compiled into MO/JSON. It should be: * Create a new POT file (with empty translations) using xgettext --join-existing. * Merge the existing PO file with the POT file (using msgmerge) This logic exists already in univention-ucs-translation-merge.
*** Bug 42810 has been marked as a duplicate of this bug. ***
Rev. 77964: The logic issues are resolved. PO can now be concatenated, which enables us to build a single PO template from mixed source types, e.g. HTML and JS files in univention-management-console. In the future it would be beneficial to move those catalog operations to dh_umc completely and not rely on message_catalogs at all. Package: univention-ucs-translation-template Version: 4.2.1-0A~4.2.0.201703201036 Branch: ucs_4.2-0 TODO: changelog
AFAIS, this looks good now. I used it for a few packages and the output is fine. → VERIFIED
UCS 4.2 has been released: https://docs.software-univention.de/release-notes-4.2-0-en.html https://docs.software-univention.de/release-notes-4.2-0-de.html If this error occurs again, please use "Clone This Bug".
*** Bug 41807 has been marked as a duplicate of this bug. ***