Qt4 GUI: localization bugs (linux and other platforms) fixed

Report bugs, bug fixes and workarounds here.
Topic author
refsteff
Posts: 17
Joined: 30.07.2011
With us: 13 years 3 months

Qt4 GUI: localization bugs (linux and other platforms) fixed

Post #1by refsteff » 24.08.2011, 18:30

Hello,

I hope these were the last bugs I found :wink:

1. No localizations in Linux:
The directory "locale" contains no .mo files (maybe after a make install under Windows but not in Linux).

Code: Select all

diff -urN celestia.org/src/celestia/qt/qtmain.cpp celestia/src/celestia/qt/qtmain.cpp
--- celestia.org/src/celestia/qt/qtmain.cpp   2011-08-19 16:04:59.000000000 +0200
+++ celestia/src/celestia/qt/qtmain.cpp   2011-08-24 18:47:44.493630131 +0200
@@ -63,9 +63,11 @@
     // Gettext integration
     setlocale(LC_ALL, "");
     setlocale(LC_NUMERIC, "C");
+#ifndef __linux
     bindtextdomain("celestia","locale");
-    bind_textdomain_codeset("celestia", "UTF-8");
     bindtextdomain("celestia_constellations","locale");
+#endif
+    bind_textdomain_codeset("celestia", "UTF-8");
     bind_textdomain_codeset("celestia_constellations", "UTF-8");
     textdomain("celestia");

 


That leads into the next bug.

2. I found no translatable strings from the .ui.h files.
So I try to make an " make update-po" in the po directory and get the error message: "File src/celengine/asterism.cpp not found" :o .
With wo blanks after asterism.cpp?! It should be one.
The reason was the file POTFILES.in contains Windows/DOS line endings (the only file in the whole po directory, and the whole src tree).
After converting the file, "make update-po" works, but again no translatable strings from the .ui.h files.

So I created a Rules-qt file (based on Rules-kde):

Code: Select all

diff -urN celestia.org/po/Rules-qt celestia/po/Rules-qt
--- celestia.org/po/Rules-qt   1970-01-01 01:00:00.000000000 +0100
+++ celestia/po/Rules-qt   2011-08-24 18:43:02.447754472 +0200
@@ -0,0 +1,15 @@
+# Additional Makefile rule to extract strings from Qt ui files.
+
+Makefile: Rules-qt
+
+XGETTEXT_OPTIONS += --qt
+
+celestia.pot-update: ../src/celestia/qt/rc.cpp
+
+../src/celestia/qt/rc.cpp:
+   extractrc ../src/celestia/qt/*.ui > ../src/celestia/qt/rc.cpp
+
+clean: clean-qt
+
+clean-qt:
+   rm -f ../src/celestia/qt/rc.cpp

The line "XGETTEXT_OPTIONS += --qt" is needed to mark format strings like "%L1" as qt format.

then I have to patch POTFILES.in to reflect the changes.
(don't forget to convert POTFILES.in to Unix/Linux format)

Code: Select all

diff -urN celestia.org/po/POTFILES.in celestia/po/POTFILES.in
--- celestia.org/po/POTFILES.in   2011-08-19 16:05:45.000000000 +0200
+++ celestia/po/POTFILES.in   2011-08-24 18:45:37.089629689 +0200
@@ -123,10 +123,6 @@
 src/celestia/qt/qtsettimedialog.cpp
 src/celestia/qt/qtsolarsystembrowser.cpp
 src/celestia/qt/qttimetoolbar.cpp
+src/celestia/qt/rc.cpp
 src/celestia/qt/xbel.cpp
 
-# Qt headers generated from reading UI files
-src/celestia/qt/ui/ui_addbookmark.h
-src/celestia/qt/ui/ui_newbookmarkfolder.h
-src/celestia/qt/ui/ui_organizebookmarks.h
-src/celestia/qt/ui/ui_preferences.h

Now I get translatable strings and the next bug was rising :?

3. The EventFinder doesn't work anymore - this bug affects all platforms with localizations
I always got an "... is not a valid object" error message.
I found the use of the "simple" method of addItem in the planetSelect combobox was wrong.

Code: Select all

--- celestia.org/src/celestia/qt/qteventfinder.cpp   2011-08-19 16:04:59.000000000 +0200
+++ celestia/src/celestia/qt/qteventfinder.cpp   2011-08-24 18:47:18.330628794 +0200
@@ -598,12 +598,12 @@
     layout->addWidget(subgroup);
 
     planetSelect = new QComboBox();
-    planetSelect->addItem(_("Earth"));
-    planetSelect->addItem(_("Jupiter"));
-    planetSelect->addItem(_("Saturn"));
-    planetSelect->addItem(_("Uranus"));
-    planetSelect->addItem(_("Neptune"));
-    planetSelect->addItem(_("Pluto"));
+    planetSelect->addItem(_("Earth"), "Earth");
+    planetSelect->addItem(_("Jupiter"), "Jupiter");
+    planetSelect->addItem(_("Saturn"), "Saturn");
+    planetSelect->addItem(_("Uranus"), "Uranus");
+    planetSelect->addItem(_("Neptune"), "Neptune");
+    planetSelect->addItem(_("Pluto"), "Pluto");
     layout->addWidget(planetSelect);
 
     QPushButton* findButton = new QPushButton(_("Find eclipses"));

Now it works again.

That's all for today :)

See you
Specs: OpenSUSE 11.2 (modified), nVidia Geforce 9400 GT, Intel E7500, celestia svn 5166 Qt4

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Qt4 GUI: localization bugs (linux and other platforms) f

Post #2by Fenerit » 24.08.2011, 22:27

Thank-you for your help here. 8)
Never at rest.
Massimo

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: Qt4 GUI: localization bugs (linux and other platforms) f

Post #3by Vincent » 26.08.2011, 08:22

Hi refsteff,

Thanks for your precious help on debugging the localization code.
I've added i18n support to the qt4 version of Celestia, but since I'm
on windows exclusively, I can't track the linux bugs.

I've been personnaly building the ui.h files using the qt integrated ui compiler:

Code: Select all

uic -tr _ addbookmark.ui -o ui/ui_addbookmark.h
uic -tr _ newbookmarkfolder.ui -o ui/ui_newbookmarkfolder.h
uic -tr _ organizebookmarks.ui -o ui/ui_organizebookmarks.h
uic -tr _ preferences.ui -o ui/ui_preferences.h

Then I've been extracting the translation files, e.g., fr.po, using:

Code: Select all

xgettext -j --omit-header --keyword=_ -o fr.po -f POTFILES_qt.in
And everything went fine...

But adding the Rules-qt file is definitely the right thing to do to get the ui.h files
extracted with a "make update-po", since this is the process we've been using until now.
I unable test your change, though, because I can't get the autotools working on windows...

As to the EventFinder issue, I didn't get any compilation error with MSVC++ 2008 Express,
not even a compiler warning, which is quite strange...

I'll submit all your i18n fixes to the devs list, and I'll be commiting them ASAP if our linux devs are
ok with them. Also, Chris L. may add you to the devs mailing list, which would be an even better option. :)
Last edited by Vincent on 28.08.2011, 08:54, edited 1 time in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
refsteff
Posts: 17
Joined: 30.07.2011
With us: 13 years 3 months

Re: Qt4 GUI: localization bugs (linux and other platforms) f

Post #4by refsteff » 26.08.2011, 12:19

Hello Vincent,
Vincent wrote:As to the EventFinder issue, I didn't get any compilation error with MSVC++ 2008 Express,
not even a compiler warning, which is quite strange...
Maybe I have to point out clearer what I mean. The error message came from celestia.
The method is not wrong , you get what you want :wink:
If you leave the second parameter out, it returns (in this case) the translated string and celestia expected an untranslated object name.
There are a lot of classes and methods in Qt that behave the same. If you leave a parameter out, it takes a default value.
That's sometimes a little bit confusing, to be sure you have to read the docs.

Vincent wrote:I'll submit all your i18n fixes to the devs list, and I'll be commiting them ASAP if our linux devs are
ok with them. Also, Chris L. may add you to the devs mailing list, which would be an even better option. :)
Maybe, but I'm really not a programmer. I can adapt code from others, see if it fits my needs and if it works.
I don't know anything about c++, but years ago I spent my time with 8/16 bit assembler and use Turbo Vision from Borland for a little GUI programming.
A GUI toolkit like Qt is similar to Turbo Vision, that's helps a lot and the Celestia source is (partially :wink: ) readable as a book.
For me it's fun to test a program that I like (my friends say "He is bug hunting, don't disturb" :lol: ).
So, if I can help I will do.

See you
Specs: OpenSUSE 11.2 (modified), nVidia Geforce 9400 GT, Intel E7500, celestia svn 5166 Qt4


Return to “Bugs”