Merge lp:~agateau/unity-2d/do-not-update-po-at-build-time into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 426
Merged at revision: 425
Proposed branch: lp:~agateau/unity-2d/do-not-update-po-at-build-time
Merge into: lp:unity-2d/3.0
Diff against target: 63 lines (+52/-2)
1 file modified
po/CMakeLists.txt (+52/-2)
To merge this branch: bzr merge lp:~agateau/unity-2d/do-not-update-po-at-build-time
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) code functional Approve
Review via email: mp+52031@code.launchpad.net

Commit message

[translations] Update .po files in the 'update-po' make target, not in the 'all' target.

Description of the change

This change moves the update of the .po files to the update-po target. This way .po files are not updated when running `make`, avoiding the need to revert the changes.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Functional tests are ok. I’ll move on to the code review now.

review: Approve (functional)
425. By Aurélien Gâteau

Make sure the 'msgfmt' target actually builds all the .gmo files

426. By Aurélien Gâteau

typo--

Revision history for this message
Olivier Tilloy (osomon) wrote :

With the latest changes, works as expected and looks good enough to my cmake-untrained eye.

review: Approve (code functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/CMakeLists.txt'
2--- po/CMakeLists.txt 2011-02-21 16:00:29 +0000
3+++ po/CMakeLists.txt 2011-03-03 16:21:40 +0000
4@@ -1,7 +1,57 @@
5+# This macro is based on the GETTEXT_CREATE_TRANSLATIONS from FindGettext.cmake
6+# but it does not modify the .po files at build time.
7+#
8+# It creates two main targets: msgfmt and msgmerge.
9+#
10+# - msgfmt turns .po files into .gmo files. msgfmt is added as a dependency to
11+# the all target. The .gmo files are then installed at the right place.
12+#
13+# - msgmerge updates the .po files from the .pot file. It must be called
14+# manually.
15+#
16+# Arguments: .pot file, then all .po files
17+macro(create_translation_targets _potFile)
18+ set(_gmoFiles)
19+ get_filename_component(_potBasename ${_potFile} NAME_WE)
20+ get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
21+
22+ add_custom_target(msgmerge)
23+
24+ foreach(_currentPoFile ${ARGN})
25+ get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
26+ get_filename_component(_lang ${_absFile} NAME_WE)
27+ set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
28+
29+ # Build a .gmo file from the current .po
30+ add_custom_command(
31+ OUTPUT ${_gmoFile}
32+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
33+ DEPENDS ${_absFile}
34+ )
35+ set(_gmoFiles ${_gmoFiles} ${_gmoFile})
36+
37+ # Extend the msgmerge target to merge the current .po
38+ add_custom_target(msgmerge-${_lang}
39+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
40+ DEPENDS ${_absPotFile} ${_absFile}
41+ )
42+ add_dependencies(msgmerge msgmerge-${_lang})
43+
44+ # Install .gmo
45+ install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
46+ endforeach(_currentPoFile)
47+
48+ # Create the msgfmt target, building all .gmo files
49+ add_custom_target(msgfmt ALL DEPENDS ${_gmoFiles})
50+endmacro(create_translation_targets)
51+
52 file(GLOB PO_FILES *.po)
53
54-add_custom_target(update-po
55+create_translation_targets(unity-2d.pot ${PO_FILES})
56+
57+add_custom_target(update-unity-2d-pot
58 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/update-unity-2d-pot
59 )
60
61-gettext_create_translations(unity-2d.pot ALL ${PO_FILES})
62+add_custom_target(update-po)
63+add_dependencies(update-po update-unity-2d-pot msgmerge)

Subscribers

People subscribed via source and target branches