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

Proposed by Larry Price
Status: Merged
Approved by: Pete Woods
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 Approve
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.
Revision history for this message
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

Test alternative language (python) translations

Revision history for this message
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.

Revision history for this message
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
=== modified file 'debian/tests/intltool'
--- debian/tests/intltool 2017-02-22 19:36:22 +0000
+++ debian/tests/intltool 2017-03-28 17:53:51 +0000
@@ -28,7 +28,7 @@
28 make install28 make install
29)29)
3030
31# Check the translatable strings have been extracted from the .ini and .cpp files31# Check the translatable strings have been extracted from the source files
32check_potfile() {32check_potfile() {
33 # Print using a similar format to glib-test33 # Print using a similar format to glib-test
34 echo -n "/potfile/$1: "34 echo -n "/potfile/$1: "
@@ -48,11 +48,16 @@
48 fi48 fi
49}49}
5050
51# From the C source
51check_potfile 'msgid "FooApp"'52check_potfile 'msgid "FooApp"'
52check_potfile 'msgid "FooApp is really great"'53check_potfile 'msgid "FooApp is really great"'
53check_potfile 'msgid "Hello FooApp!"'54check_potfile 'msgid "Hello FooApp!"'
54check_potfile 'msgid "this translation should be ignored"' 155check_potfile 'msgid "this translation should be ignored"' 1
5556
57# From the python
58check_potfile 'msgid "Python apps can be translated, too"'
59check_potfile 'msgid "Regardless of single- or double-quotes"'
60
56# From the schema file61# From the schema file
57check_potfile "Just a test"62check_potfile "Just a test"
58check_potfile "No really, it's just a test."63check_potfile "No really, it's just a test."
5964
=== modified file 'examples/intltool-demo/CMakeLists.txt'
--- examples/intltool-demo/CMakeLists.txt 2017-02-15 21:53:15 +0000
+++ examples/intltool-demo/CMakeLists.txt 2017-03-28 17:53:51 +0000
@@ -21,3 +21,4 @@
2121
22add_subdirectory(po)22add_subdirectory(po)
23add_subdirectory(src)23add_subdirectory(src)
24add_subdirectory(python)
2425
=== modified file 'examples/intltool-demo/po/CMakeLists.txt'
--- examples/intltool-demo/po/CMakeLists.txt 2017-02-22 19:59:32 +0000
+++ examples/intltool-demo/po/CMakeLists.txt 2017-03-28 17:53:51 +0000
@@ -4,8 +4,9 @@
4 POTFILES_TEMPLATE "POTFILES.in.in"4 POTFILES_TEMPLATE "POTFILES.in.in"
5 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}5 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
6 COPYRIGHT_HOLDER "Foocorp Ltd."6 COPYRIGHT_HOLDER "Foocorp Ltd."
7 FILE_GLOBS "${CMAKE_SOURCE_DIR}/*.gschema.xml.in"7 FILE_GLOBS "${CMAKE_SOURCE_DIR}/*.gschema.xml.in;${CMAKE_SOURCE_DIR}/python/*.py"
8 FILTER ".*test.*"8 FILTER ".*test.*"
9 LANGUAGE "python"
9)10)
1011
11intltool_install_translations(12intltool_install_translations(
1213
=== modified file 'examples/intltool-demo/po/en_AU.po'
--- examples/intltool-demo/po/en_AU.po 2017-02-15 21:53:15 +0000
+++ examples/intltool-demo/po/en_AU.po 2017-03-28 17:53:51 +0000
@@ -38,3 +38,11 @@
38#: ../translated.gschema.xml.in.h:238#: ../translated.gschema.xml.in.h:2
39msgid "No really, it's just a test."39msgid "No really, it's just a test."
40msgstr "G'day mate, it's a test!"40msgstr "G'day mate, it's a test!"
41
42#: ../python/other_language_translations.py:7
43msgid "Python apps can be translated, too"
44msgstr "Crikey, watch the snake!"
45
46#: ../python/other_language_translations.py:8
47msgid "Regardless of single- or double-quotes"
48msgstr "This, that, or the other"
4149
=== added directory 'examples/intltool-demo/python'
=== added file 'examples/intltool-demo/python/CMakeLists.txt'
--- examples/intltool-demo/python/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/intltool-demo/python/CMakeLists.txt 2017-03-28 17:53:51 +0000
@@ -0,0 +1,2 @@
1install(PROGRAMS other_language_translations.py
2 DESTINATION usr/bin)
03
=== added file 'examples/intltool-demo/python/other_language_translations.py'
--- examples/intltool-demo/python/other_language_translations.py 1970-01-01 00:00:00 +0000
+++ examples/intltool-demo/python/other_language_translations.py 2017-03-28 17:53:51 +0000
@@ -0,0 +1,8 @@
1#!/usr/bin/env python
2
3import gettext
4gettext.textdomain('libertine')
5_ = gettext.gettext
6
7print(_('Python apps can be translated, too'))
8print(_("Regardless of single- or double-quotes"))
09
=== modified file 'src/Intltool/IntltoolConfig.cmake'
--- src/Intltool/IntltoolConfig.cmake 2017-02-28 17:46:57 +0000
+++ src/Intltool/IntltoolConfig.cmake 2017-03-28 17:53:51 +0000
@@ -136,8 +136,15 @@
136 set(${OUTPUT} "${_tmp}" PARENT_SCOPE)136 set(${OUTPUT} "${_tmp}" PARENT_SCOPE)
137endfunction()137endfunction()
138138
139macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS ARG_COPYRIGHT_HOLDER)139macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS
140 set(_KEYWORDS "XGETTEXT_KEYWORDS=--c++")140 ARG_COPYRIGHT_HOLDER ARG_LANGUAGE)
141 set(_KEYWORDS "XGETTEXT_KEYWORDS=")
142 if(NOT "${ARG_LANGUAGE}" STREQUAL "")
143 set(_KEYWORDS "${_KEYWORDS}--language ${ARG_LANGUAGE} ")
144 else()
145 set(_KEYWORDS "${_KEYWORDS}--c++")
146 endif()
147
141 if(NOT "${ARG_COPYRIGHT_HOLDER}" STREQUAL "")148 if(NOT "${ARG_COPYRIGHT_HOLDER}" STREQUAL "")
142 set(_KEYWORDS "${_KEYWORDS} --copyright-holder='${ARG_COPYRIGHT_HOLDER}'")149 set(_KEYWORDS "${_KEYWORDS} --copyright-holder='${ARG_COPYRIGHT_HOLDER}'")
143 endif()150 endif()
@@ -190,7 +197,7 @@
190197
191function(INTLTOOL_UPDATE_POTFILE)198function(INTLTOOL_UPDATE_POTFILE)
192 set(_options ALL UBUNTU_SDK_DEFAULTS)199 set(_options ALL UBUNTU_SDK_DEFAULTS)
193 set(_oneValueArgs COPYRIGHT_HOLDER GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY POTFILES_TEMPLATE)200 set(_oneValueArgs COPYRIGHT_HOLDER GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY POTFILES_TEMPLATE LANGUAGE)
194 set(_multiValueArgs KEYWORDS FILE_GLOBS FILTER)201 set(_multiValueArgs KEYWORDS FILE_GLOBS FILTER)
195202
196 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})203 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
@@ -215,10 +222,10 @@
215 endif()222 endif()
216223
217 if(_ARG_KEYWORDS)224 if(_ARG_KEYWORDS)
218 _write_intltool_makefile_in(${_PO_DIRECTORY} _ARG_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}")225 _write_intltool_makefile_in(${_PO_DIRECTORY} _ARG_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}" "${_ARG_LANGUAGE}")
219 elseif(_ARG_UBUNTU_SDK_DEFAULTS)226 elseif(_ARG_UBUNTU_SDK_DEFAULTS)
220 set(_UBUNTU_SDK_DEFAULT_KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_")227 set(_UBUNTU_SDK_DEFAULT_KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_")
221 _write_intltool_makefile_in(${_PO_DIRECTORY} _UBUNTU_SDK_DEFAULT_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}")228 _write_intltool_makefile_in(${_PO_DIRECTORY} _UBUNTU_SDK_DEFAULT_KEYWORDS "${_ARG_COPYRIGHT_HOLDER}" "${_ARG_LANGUAGE}")
222 endif()229 endif()
223 230
224 set(_FILE_GLOBS231 set(_FILE_GLOBS

Subscribers

People subscribed via source and target branches

to all changes: