Merge lp:~larryprice/cmake-extras/multiple-programming-languages into lp:cmake-extras

Proposed by Larry Price on 2017-03-24
Status: Merged
Approved by: Pete Woods on 2017-04-03
Approved revision: 74
Merged at revision: 74
Proposed branch: lp:~larryprice/cmake-extras/multiple-programming-languages
Merge into: lp:cmake-extras
Diff against target: 134 lines (+39/-7)
7 files modified
debian/tests/intltool (+6/-1)
examples/intltool-demo/CMakeLists.txt (+1/-0)
examples/intltool-demo/po/CMakeLists.txt (+2/-1)
examples/intltool-demo/po/en_AU.po (+8/-0)
examples/intltool-demo/python/CMakeLists.txt (+2/-0)
examples/intltool-demo/python/other_language_translations.py (+8/-0)
src/Intltool/IntltoolConfig.cmake (+12/-5)
To merge this branch: bzr merge lp:~larryprice/cmake-extras/multiple-programming-languages
Reviewer Review Type Date Requested Status
Pete Woods 2017-03-24 Approve on 2017-04-03
Review via email: mp+320967@code.launchpad.net

Commit message

Allow passing in an argument to specify alternative programming language to xgettext.

Description of the change

Allow passing in an argument to specify programming language(s) to xgettext. Currently the system simply defaults to using C++ only.

To post a comment you must log in.
Pete Woods (pete-woods) wrote :

Thanks for this fix, but please add a test to the existing suite in "debian/tests/intltool" (which relies on the example in "examples/intltool-demo/".

review: Needs Fixing
74. By Larry Price on 2017-03-28

Test alternative language (python) translations

Larry Price (larryprice) wrote :

Added a test. After some digging, I also found out that xgettext ignores all but the last arguments to `--language`, so I've updated the argument to only take in a single alternative language.

Pete Woods (pete-woods) wrote :

Brilliant, thanks very much!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/tests/intltool'
2--- debian/tests/intltool 2017-02-22 19:36:22 +0000
3+++ debian/tests/intltool 2017-03-28 17:53:51 +0000
4@@ -28,7 +28,7 @@
5 make install
6 )
7
8-# Check the translatable strings have been extracted from the .ini and .cpp files
9+# Check the translatable strings have been extracted from the source files
10 check_potfile() {
11 # Print using a similar format to glib-test
12 echo -n "/potfile/$1: "
13@@ -48,11 +48,16 @@
14 fi
15 }
16
17+# From the C source
18 check_potfile 'msgid "FooApp"'
19 check_potfile 'msgid "FooApp is really great"'
20 check_potfile 'msgid "Hello FooApp!"'
21 check_potfile 'msgid "this translation should be ignored"' 1
22
23+# From the python
24+check_potfile 'msgid "Python apps can be translated, too"'
25+check_potfile 'msgid "Regardless of single- or double-quotes"'
26+
27 # From the schema file
28 check_potfile "Just a test"
29 check_potfile "No really, it's just a test."
30
31=== modified file 'examples/intltool-demo/CMakeLists.txt'
32--- examples/intltool-demo/CMakeLists.txt 2017-02-15 21:53:15 +0000
33+++ examples/intltool-demo/CMakeLists.txt 2017-03-28 17:53:51 +0000
34@@ -21,3 +21,4 @@
35
36 add_subdirectory(po)
37 add_subdirectory(src)
38+add_subdirectory(python)
39
40=== modified file 'examples/intltool-demo/po/CMakeLists.txt'
41--- examples/intltool-demo/po/CMakeLists.txt 2017-02-22 19:59:32 +0000
42+++ examples/intltool-demo/po/CMakeLists.txt 2017-03-28 17:53:51 +0000
43@@ -4,8 +4,9 @@
44 POTFILES_TEMPLATE "POTFILES.in.in"
45 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
46 COPYRIGHT_HOLDER "Foocorp Ltd."
47- FILE_GLOBS "${CMAKE_SOURCE_DIR}/*.gschema.xml.in"
48+ FILE_GLOBS "${CMAKE_SOURCE_DIR}/*.gschema.xml.in;${CMAKE_SOURCE_DIR}/python/*.py"
49 FILTER ".*test.*"
50+ LANGUAGE "python"
51 )
52
53 intltool_install_translations(
54
55=== modified file 'examples/intltool-demo/po/en_AU.po'
56--- examples/intltool-demo/po/en_AU.po 2017-02-15 21:53:15 +0000
57+++ examples/intltool-demo/po/en_AU.po 2017-03-28 17:53:51 +0000
58@@ -38,3 +38,11 @@
59 #: ../translated.gschema.xml.in.h:2
60 msgid "No really, it's just a test."
61 msgstr "G'day mate, it's a test!"
62+
63+#: ../python/other_language_translations.py:7
64+msgid "Python apps can be translated, too"
65+msgstr "Crikey, watch the snake!"
66+
67+#: ../python/other_language_translations.py:8
68+msgid "Regardless of single- or double-quotes"
69+msgstr "This, that, or the other"
70
71=== added directory 'examples/intltool-demo/python'
72=== added file 'examples/intltool-demo/python/CMakeLists.txt'
73--- examples/intltool-demo/python/CMakeLists.txt 1970-01-01 00:00:00 +0000
74+++ examples/intltool-demo/python/CMakeLists.txt 2017-03-28 17:53:51 +0000
75@@ -0,0 +1,2 @@
76+install(PROGRAMS other_language_translations.py
77+ DESTINATION usr/bin)
78
79=== added file 'examples/intltool-demo/python/other_language_translations.py'
80--- examples/intltool-demo/python/other_language_translations.py 1970-01-01 00:00:00 +0000
81+++ examples/intltool-demo/python/other_language_translations.py 2017-03-28 17:53:51 +0000
82@@ -0,0 +1,8 @@
83+#!/usr/bin/env python
84+
85+import gettext
86+gettext.textdomain('libertine')
87+_ = gettext.gettext
88+
89+print(_('Python apps can be translated, too'))
90+print(_("Regardless of single- or double-quotes"))
91
92=== modified file 'src/Intltool/IntltoolConfig.cmake'
93--- src/Intltool/IntltoolConfig.cmake 2017-02-28 17:46:57 +0000
94+++ src/Intltool/IntltoolConfig.cmake 2017-03-28 17:53:51 +0000
95@@ -136,8 +136,15 @@
96 set(${OUTPUT} "${_tmp}" PARENT_SCOPE)
97 endfunction()
98
99-macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS ARG_COPYRIGHT_HOLDER)
100- set(_KEYWORDS "XGETTEXT_KEYWORDS=--c++")
101+macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS
102+ ARG_COPYRIGHT_HOLDER ARG_LANGUAGE)
103+ set(_KEYWORDS "XGETTEXT_KEYWORDS=")
104+ if(NOT "${ARG_LANGUAGE}" STREQUAL "")
105+ set(_KEYWORDS "${_KEYWORDS}--language ${ARG_LANGUAGE} ")
106+ else()
107+ set(_KEYWORDS "${_KEYWORDS}--c++")
108+ endif()
109+
110 if(NOT "${ARG_COPYRIGHT_HOLDER}" STREQUAL "")
111 set(_KEYWORDS "${_KEYWORDS} --copyright-holder='${ARG_COPYRIGHT_HOLDER}'")
112 endif()
113@@ -190,7 +197,7 @@
114
115 function(INTLTOOL_UPDATE_POTFILE)
116 set(_options ALL UBUNTU_SDK_DEFAULTS)
117- set(_oneValueArgs COPYRIGHT_HOLDER GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY POTFILES_TEMPLATE)
118+ set(_oneValueArgs COPYRIGHT_HOLDER GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY POTFILES_TEMPLATE LANGUAGE)
119 set(_multiValueArgs KEYWORDS FILE_GLOBS FILTER)
120
121 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
122@@ -215,10 +222,10 @@
123 endif()
124
125 if(_ARG_KEYWORDS)
126- _write_intltool_makefile_in(${_PO_DIRECTORY} _ARG_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}")
127+ _write_intltool_makefile_in(${_PO_DIRECTORY} _ARG_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}" "${_ARG_LANGUAGE}")
128 elseif(_ARG_UBUNTU_SDK_DEFAULTS)
129 set(_UBUNTU_SDK_DEFAULT_KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_")
130- _write_intltool_makefile_in(${_PO_DIRECTORY} _UBUNTU_SDK_DEFAULT_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}")
131+ _write_intltool_makefile_in(${_PO_DIRECTORY} _UBUNTU_SDK_DEFAULT_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}" "${_ARG_LANGUAGE}")
132 endif()
133
134 set(_FILE_GLOBS

Subscribers

People subscribed via source and target branches

to all changes: