diff --git a/translations/.gitignore b/translations/.gitignore index cf75c4f3f916fc1399785b7d58b9dcd00f9f379f..fa63547272879a9e69e4a9c2e8b0732347ffd540 100644 --- a/translations/.gitignore +++ b/translations/.gitignore @@ -1,3 +1,6 @@ -*-main.c +*-main.c* *.mo gettext +*.qm +qt-linguist +Makefile.linguist diff --git a/translations/Linguist.pro b/translations/Linguist.pro new file mode 100644 index 0000000000000000000000000000000000000000..3c20502228d7001c5f1b3b601b62fd811f5f5506 --- /dev/null +++ b/translations/Linguist.pro @@ -0,0 +1,6 @@ +QT += core + +TARGET = qt-linguist + +SOURCES += linguist-main.cpp setuplocale.c linguist.cpp +TRANSLATIONS = example_sv.ts diff --git a/translations/Makefile b/translations/Makefile index 85000ea455bcb370eccaa9804ddf273ad35a048c..e68e6aaf9617161c0a27edee2d58a3357cf138dc 100644 --- a/translations/Makefile +++ b/translations/Makefile @@ -1,8 +1,16 @@ -all: gettext-main.c linguist-main.c +.PHONY: qt-linguist + +all: gettext-main.c linguist-main.cpp gettext qt-linguist gettext: gettext-main.c setuplocale.c gettext.c gettext-main.c: base.c cp $< $@ -linguist-main.c: base.c +linguist-main.cpp: base.c cp $< $@ + +qt-linguist: Makefile.linguist + $(MAKE) -f Makefile.linguist + +Makefile.linguist: Linguist.pro + qmake -o $@ $< diff --git a/translations/base.c b/translations/base.c index 03eace7274ae24c02ae3e63339f85d5fff4e9657..02fdf80d4302834fd5ebf3b1a4a1c4b458a2cf1c 100644 --- a/translations/base.c +++ b/translations/base.c @@ -1,19 +1,29 @@ #include <stdio.h> +#if __cplusplus +extern "C" void setuplocale(); +#else void setup(); void setuplocale(); +#endif int main(int argc, char** argv) { setuplocale(); +#if __cplusplus + /* For Qt: Your code here as it is more convenient than a separate function in C++. + * Setup a QCoreApplication (an application without GUI) and install a translator. + */ +#else setup(); - /* TODO: You need to update this code to output translated strings +#endif + /* You need to update this code to output translated strings * Note that you should make gettext-main.c linguist-main.c and modify * those files rather than base.c */ - printf("The current language is the default (C/POSIX)\n"); - printf("The horse can run.\n"); - printf("How fast can the horse run?\n"); - printf("It typically runs at speed of less than 50 km/h.\n"); + puts("The current language is the default (C/POSIX)\n"); + puts("The horse can run.\n"); + puts("How fast can the horse run?\n"); + puts("It typically runs at speed of less than 50 km/h.\n"); return 0; } diff --git a/translations/gettext.c b/translations/gettext.c index 657b2bae0e8af02dacfd86c00f0415018e453e8c..e3ee68479fa681da4597291f3395b4d1d59a9845 100644 --- a/translations/gettext.c +++ b/translations/gettext.c @@ -1,7 +1,4 @@ -#include <locale.h> #include <libintl.h> -#include <stdio.h> -#include <stdlib.h> void setup() {