Debian Codegraph @

po/po.pro

raw
1 include(../common-project-config.pri)
2 TEMPLATE = subdirs
3
4 PROJECTNAME = "lomiri-system-settings-online-accounts"
5
6 SETTINGSFILES = ../system-settings-plugin/*.settings
7
8 SOURCECODE = ../system-settings-plugin/*.qml
9
10 BUILDDIR = ../.build
11 SETTINGSFILETEMP = $${BUILDDIR}/settings.js
12
13 message("")
14 message(" Project Name: $$PROJECTNAME ")
15 message(" Source Code: $$SOURCECODE ")
16 message("")
17 message(" Run 'make pot' to generate the pot file from source code. ")
18 message("")
19
20 ## Generate pot file 'make pot'
21 potfile.target = pot
22 potfile.commands = xgettext \
23 -o $${PROJECTNAME}.pot \
24 --copyright=\"Canonical Ltd. \" \
25 --package-name $${PROJECTNAME} \
26 --qt --c++ --add-comments=TRANSLATORS \
27 --keyword=tr --keyword=tr:1,2 --keyword=dtr:2 --from-code=UTF-8 \
28 $${SOURCECODE} $${SETTINGSFILETEMP}
29 potfile.depends = settingsfiles
30 QMAKE_EXTRA_TARGETS += potfile
31
32 ## Do not use this rule directly. It's a dependency rule to
33 ## generate an intermediate file to extract translatable
34 ## strings from the .settings files
35 settingsfiles.target = settingsfiles
36 settingsfiles.commands = awk \'BEGIN { FS=\": \" }; /name/ {print \"var s = i18n.tr(\" \$$2 \");\"}\' $${SETTINGSFILES} | tr -d ',' > $${SETTINGSFILETEMP}
37 settingsfiles.depends = makebuilddir
38 QMAKE_EXTRA_TARGETS += settingsfiles
39
40 ## Dependency rule to create the temporary build dir
41 makebuilddir.target = makebuilddir
42 makebuilddir.commands = mkdir -p $${BUILDDIR}
43 QMAKE_EXTRA_TARGETS += makebuilddir
44
45 PO_FILES = $$system(ls *.po)
46
47 ## Install the translations
48 install.target = install
49 install_mo_commands =
50 for(po_file, PO_FILES) {
51 mo_name = $$replace(po_file,.po,)
52 mo_targetpath = $(INSTALL_ROOT)$${INSTALL_PREFIX}/share/locale/$${mo_name}/LC_MESSAGES
53 mo_target = $${mo_targetpath}/$${PROJECTNAME}.mo
54 !isEmpty(install_mo_commands): install_mo_commands += &&
55 install_mo_commands += test -d $$mo_targetpath || mkdir -p $$mo_targetpath
56 install_mo_commands += && cp $${mo_name}.mo $$mo_target
57 }
58 install.commands = $$install_mo_commands
59 install.depends = mofiles
60 QMAKE_EXTRA_TARGETS += install
61
62 ## Build $locale.mo from the $locale.po files (called by the installed rule)
63 mofiles.target = mofiles
64 mofiles_po_commands =
65 for(po_file, PO_FILES) {
66 po_name = $$replace(po_file,.po,)
67 install_po_commands += msgfmt $$po_file -o $${po_name}.mo;
68 }
69 mofiles.commands = $$install_po_commands
70 QMAKE_EXTRA_TARGETS += mofiles
71
72 ## Rule to clean the products of the build
73 clean.target = clean
74 clean.commands = rm -Rf $${BUILDDIR} *.mo
75 QMAKE_EXTRA_TARGETS += clean