Skip to content

Commit 068b404

Browse files
committed
Update qmake for translations
1 parent 3442821 commit 068b404

File tree

5 files changed

+58
-62
lines changed

5 files changed

+58
-62
lines changed

common.pri

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ CONFIG(debug, debug|release) {
1111
DEFINES *= QT_NO_DEBUG_OUTPUT # QT_NO_INFO_OUTPUT
1212
}
1313

14-
APP_BINS = $${PROJECT_ROOT_PATH}/bin/$${BUILD_FLAG}
14+
APP_BINS = $$shadowed($${PROJECT_ROOT_PATH})/bin
1515

1616
CONFIG *= c++11
1717
CONFIG -= debug_and_release debug_and_release_target
1818

1919
# moc doesn't detect Q_OS_LINUX correctly, so add this to make it work
2020
linux*:DEFINES *= __linux__
2121

22-
LANG_PATH = $${PROJECT_ROOT_PATH}/lang
23-
# define locales for translation
24-
LANG_LIST = pl ca de fi cs_CZ es nl ru
25-
2622
!CONFIG(staticlib) {
2723
DESTDIR = $$APP_BINS
2824
}
@@ -136,36 +132,6 @@ defineReplace(findFiles) {
136132
}
137133

138134

139-
#
140-
# function tsFiles(modulename, locales)
141-
# Returns a list of files with this $${LANG_PATH}/modulename_lang.ts
142-
# example :
143-
# TARGET = bar
144-
# LANG_PATH = lang
145-
# LANG_LIST = pl fr de
146-
# $$tsFiles(foo, ru en) returns lang/foo_ru.ts lang/foo_en.ts
147-
# $$tsFiles(foo) returns lang/foo_pl.ts lang/foo_fr.ts lang/foo_de.ts
148-
# $$tsFiles() returns lang/bar_pl.ts lang/bar_fr.ts lang/bar_de.ts
149-
#
150-
defineReplace(tsFiles) {
151-
module_name = $$1
152-
locales = $$2
153-
154-
!defined(1, var) {
155-
module_name = $$TARGET
156-
}
157-
158-
!defined(2, var) {
159-
locales = $$LANG_LIST
160-
}
161-
162-
for(lang, locales) {
163-
file_list += $${LANG_PATH}/$${module_name}_$${lang}.ts
164-
}
165-
166-
return ($$file_list)
167-
}
168-
169135
defineReplace(getVersion) {
170136
version_file = gcodeshared/include/version.h
171137
!exists ($${PROJECT_ROOT_PATH}/$${version_file}): error(In function getVersion: File \"$${version_file}\" not found)

gcodeshared/utils/medium.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ int Medium::checkLaunch()
110110

111111
#endif // Q_OS_WIN
112112

113-
dir = dir.section(SLASH, -2, -1);
114-
115-
if (dir.startsWith(BIN) && (dir.endsWith(DEBUG) || dir.endsWith(RELEASE))) {
113+
if (dir.contains("build")) {
116114
return LAUNCH_SANDBOX;
117115
}
118116

@@ -144,7 +142,7 @@ void Medium::setupDirs()
144142
break;
145143

146144
case LAUNCH_SANDBOX:
147-
shareDir = rootDir.section(SLASH, 0, -3);
145+
shareDir = rootDir.section(SLASH, 0, -2);
148146
langDir = shareDir;
149147
mSettingsDir = shareDir;
150148
mSettingsDir.append(SLASH_BIN);

gcodeworkshop_top.pro

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,8 @@ SUBDIRS = 3rdparty gcodeshared addons gcodeworkshop gcodefileserver
55

66

77
include(common.pri)
8+
include(lang/lang.pri)
89

9-
QMAKE_EXTRA_TARGETS += lupdate
10-
lupdate.depends = lupdateGCodeWorkShop lupdateKdiff3
11-
QMAKE_EXTRA_TARGETS += lupdateGCodeWorkShop lupdateKdiff3
12-
lupdateGCodeWorkShop.commands = $$[QT_INSTALL_BINS]/lupdate \
13-
$$PROJECT_ROOT_PATH/gcodeworkshop \
14-
$$PROJECT_ROOT_PATH/gcodeshared \
15-
$$PROJECT_ROOT_PATH/gcodefileserver \
16-
$$PROJECT_ROOT_PATH/addons \
17-
-ts $$tsFiles(gcodeworkshop)
18-
lupdateKdiff3.commands = $$[QT_INSTALL_BINS]/lupdate \
19-
$$PROJECT_ROOT_PATH/3rdparty/kdiff3 \
20-
-ts $$tsFiles(kdiff3)
21-
22-
QMAKE_EXTRA_TARGETS += lrelease
23-
lrelease.commands = $$[QT_INSTALL_BINS]/lrelease \
24-
$$tsFiles(gcodeworkshop) \
25-
$$tsFiles(kdiff3)
26-
27-
translate.files = $$LANG_PATH/*.qm
2810
examples.files = $$PROJECT_ROOT_PATH/examples/*
2911
doc.files = $$PROJECT_ROOT_PATH/README.md $$PROJECT_ROOT_PATH/doc/SerialTransmission_Help.html
3012

@@ -41,14 +23,13 @@ unix {
4123
doc.path = $${PREFIX}/share/doc/gcodeworkshop
4224
mime.path = $${PREFIX}/share/mime/packages
4325
desktop.path = $${PREFIX}/share/applications
44-
translate.path = $${PREFIX}/share/gcodeworkshop/lang
4526

4627
ICONS_BASE_PATH = $$PROJECT_ROOT_PATH/install/linux/images
4728
icons.base = $$ICONS_BASE_PATH
4829
icons.files = $$findFiles($$ICONS_BASE_PATH, *.png)
4930
icons.path = $${PREFIX}/share/icons
5031

51-
INSTALLS += translate mime desktop icons examples doc
32+
INSTALLS += mime desktop icons examples doc
5233
}
5334

5435
macx {
@@ -57,9 +38,8 @@ macx {
5738
win32 {
5839
examples.path = $${PREFIX}/examples
5940
doc.path = $${PREFIX}/doc
60-
translate.path = $${PREFIX}/lang
6141

62-
INSTALLS += translate examples doc
42+
INSTALLS += examples doc
6343
}
6444

6545
!defined(VERSION, var): VERSION = $$getVersion()

lang/lang.pri

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Make target i18n
2+
########################################
3+
4+
LANG_LIST = $$cat(languages.txt)
5+
6+
QMAKE_EXTRA_TARGETS += i18n
7+
I18N_IN = $${PWD}
8+
I18N_OUT = $$shadowed($${I18N_IN})
9+
10+
mkpath($${I18N_OUT})
11+
12+
for (LANG, LANG_LIST) {
13+
write_file($${I18N_OUT}/gcodeworkshop_$${LANG}.qm)
14+
translates.files += $${I18N_OUT}/gcodeworkshop_$${LANG}.qm
15+
QMAKE_EXTRA_TARGETS += i18n_g_$${LANG}
16+
i18n.depends += i18n_g_$${LANG}
17+
i18n_g_$${LANG}.commands = $$[QT_INSTALL_BINS]/lrelease $${I18N_IN}/gcodeworkshop_$${LANG}.ts -qm $${I18N_OUT}/gcodeworkshop_$${LANG}.qm
18+
write_file($${I18N_OUT}/kdiff3_$${LANG}.qm)
19+
translates.files += $${I18N_OUT}/kdiff3_$${LANG}.qm
20+
QMAKE_EXTRA_TARGETS += i18n_k_$${LANG}
21+
i18n.depends += i18n_k_$${LANG}
22+
i18n_k_$${LANG}.commands = $$[QT_INSTALL_BINS]/lrelease $${I18N_IN}/kdiff3_$${LANG}.ts -qm $${I18N_OUT}/kdiff3_$${LANG}.qm
23+
}
24+
25+
translates.base = $$I18N_OUT
26+
unix: translates.path = $${PREFIX}/share/gcodeworkshop/lang
27+
win32: translates.path = $${PREFIX}/lang
28+
!macx: INSTALLS += translates
29+
30+
31+
# Make target lupdate
32+
########################################
33+
34+
QMAKE_EXTRA_TARGETS += lupdate
35+
lupdate.depends = lupdateGCodeWorkShop lupdateKdiff3
36+
QMAKE_EXTRA_TARGETS += lupdateGCodeWorkShop lupdateKdiff3
37+
38+
for (LANG, LANG_LIST) {
39+
GCODEWORKSHOP_TS += $${I18N_IN}/gcodeworkshop_$${LANG}.ts
40+
KDIFF3_TS += $${I18N_IN}/kdiff3_$${LANG}.ts
41+
}
42+
43+
lupdateGCodeWorkShop.commands = $$[QT_INSTALL_BINS]/lupdate \
44+
$$PROJECT_ROOT_PATH/gcodeworkshop \
45+
$$PROJECT_ROOT_PATH/gcodeshared \
46+
$$PROJECT_ROOT_PATH/gcodefileserver \
47+
$$PROJECT_ROOT_PATH/addons \
48+
-ts $$GCODEWORKSHOP_TS
49+
lupdateKdiff3.commands = $$[QT_INSTALL_BINS]/lupdate \
50+
$$PROJECT_ROOT_PATH/3rdparty/kdiff3 \
51+
-ts $$KDIFF3_TS

lang/languages.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ca cs_CZ de es fi nl pl ru

0 commit comments

Comments
 (0)