Internationalization under Windows...

The place to discuss creating, porting and modifying Celestia's source code.
steffens
Posts: 162
Joined: 06.11.2003
With us: 21 years
Location: RP Germany

Post #21by steffens » 01.02.2006, 13:12

Christophe wrote:The GTK version is i18n ready, it already works under Linux so the only thing to do under Windows is to link against gettext.

Is it? Last time I checked Celestia-gtk/gnome there was no internationalization support. I thought this was one of the next things Pat was going to do (after 1.4.1).

steffens

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #22by Christophe » 02.02.2006, 09:40

The menus and dialogs are not translated, but the catalog files are used so the core is translated.

Here is a screenshot, it looks French enough to me ;-)
Image
Christophe

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

Post #23by Vincent » 02.02.2006, 14:18

I followed all the steps of the "Gettext FAQ". I still can't read a french word in Celestia, but I think I'm on a good way.
Feedbacks from Windows users/programmers will be very very appreciated. Here's what I did :

1- Add an invocation of AM_GNU_GETTEXT([external]) to the package's configure.in file.
> Already done by Chris in "configure.in"

2- Invoke gettextize --copy. It will do most of the autoconf/automake related work for you.
> Done

3- Add the "gettext.h" file to the package's source directory, and include it in all source files that contain translatable strings or do output via printf or fprintf.
> I added "gettext.h" to the "...\inc" folder and included it in winmain.cpp with "#include "../../inc/gettext.h". I had to replace #include "gettext.h" with #include "../../inc/gettext.h" to make the compiler find gettext.h.

4- In the source file defining the main() function of the program, add these lines to the header :
#include <locale.h>
#include "gettext.h"
> Done in winmain.cpp. (replaced #include "gettext.h" with #include "../../inc/gettext.h".)

5- ...and these lines near the beginning of the main() function:
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);

The .mo file's location is : "localedir/lang/LC_MESSAGES/domain.mo" where "domain" is the argument passed to textdomain(), "localedir" is the second argument passed to bindtextdomain(), and "lang" is the language (LL) or language and territory (LL_CC).
> I got this error :

Code: Select all

winmain.cpp(2997) : error C2065: 'PACKAGE' : undeclared identifier
winmain.cpp(2995) : error C2065: 'LOCALEDIR' : undeclared identifier
Since I didn't find any declaration of PACKAGE and LOCALEDIR anywhere, I replaced PACKAGE with "celestia" and LOCALEDIR with "%Windir%/GnuWin32/share/locale". Here are the lines I added in winmain.cpp :

Code: Select all

setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
bindtextdomain("celestia","%Windir%/../GnuWin32/share/locale");
bind_textdomain_codeset("celestia", "UTF-8");
textdomain("celestia");

- On Windows you can't set the LOCALEDIR in the Makefile : the LOCALEDIR is always defined as integer, and not as string as happens on Linux. So I installed the GnuWin32 package in C:/ roots, and I could use the environment variable %WINDIR%/../

6- Mark all strings that should be translated with _()
> Already done by Chris.

7- In every source file containing translatable strings, add these lines to the header:
#include "gettext.h"
#define _(string) gettext (string)
> Done in celestiacore.cpp. I replaced #include "gettext.h" with #include "../../inc/gettext.h".

8- You need to add an -I option to the compilation command line, so that the compiler finds the libintl.h include file. You need to add an -L option to the link command line, so that the linker finds the intl.lib library.
> My "celvars.bat" file includes the "...\inc" and "...\lib" folders :

Code: Select all

@echo off

Set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%

Set INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
Set INCLUDE=C:\Program Files\Microsoft SDK\include;%INCLUDE%
Set INCLUDE=C:\Program Files\Microsoft SDK\include\Win64\mfc;%INCLUDE%
Set INCLUDE=C:\celestia_fr\inc;%INCLUDE%

Set LIB=C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
Set LIB=C:\Program Files\Microsoft SDK\Lib;%LIB%
Set LIB=C:\Program Files\Microsoft SDK\Lib\IA64\mfc;%LIB%
Set LIB=C:\celestia_fr\lib;%LIB%

9- For running a program that uses gettext(), one needs the .bin.woe32.zip packages of gettext-runtime and libiconv. As a developer, you'll also need the xgettext and msgfmt programs that are contained in the .bin.woe32.zip package of gettext-tools.
> OK.

10- Then, you need to add an -MD option to all compilation and link command lines. MSVC has three different, mutually incompatible, compilation models (-ML, -MT, -MD); the default is -ML. intl.dll uses the -MD model, therefore the rest of the program must use -MD as well.
> I added the MFLAGS=-MD option to all the nmake command lines in winbuild.mak and makerelease.bat. Here's an example :

Code: Select all

nmake/nologo /f util.mak MFLAGS=-MD clean CFG=$(CFG)

10- You need to copy the intl.dll and iconv.dll to the directory where your .exe files are created, so that they will be found at runtime.
> OK

Sorry to insist, but any help/feedbacks from Windows users/programmers will be very very appreciated. :D
Last edited by Vincent on 05.02.2006, 15:51, edited 3 times 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

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #24by Christophe » 02.02.2006, 15:50

(Not that I mind being called Chris, but to avoid confusion with the other Chris (Laurel), it's best to refer to me as Christophe in the forums.)

Some comments:

Since you don't use the autotools to build Celestia, steps 1 and 2 are not prerequisites for you.

Step 5, PACKAGE and LOCALEDIR are defined only if you use the makefile generated by the autotools. Your solution seems ok.

Then how do you launch Celestia? Do you get any error at all?
Christophe

GlobeMaker
Posts: 216
Joined: 30.10.2005
With us: 19 years

Post #25by GlobeMaker » 02.02.2006, 16:11

Hello Vincent,

When you do everything right, but the compilation fails, try this :
delete all object files. Some bad .obj files stay in the directory.
From the command line in the /src/ directory use the command :

del *.obj /S

Then compile again.
Your wish is my command line.

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

Post #26by Vincent » 02.02.2006, 16:21

Christophe wrote:(Not that I mind being called Chris, but to avoid confusion with the other Chris (Laurel), it's best to refer to me as Christophe in the forums.)
In fact, I was refering to Chris Laurel, since I thought he wrote these lines... Sorry Christophe. :wink:

Then how do you launch Celestia? Do you get any error at all?
First, I tried to launch Celestia directly from the celestia.exe compiled file. I got no error, but no french word either...
Then I tried with the Windows command lines :

Code: Select all

cd c:\celestia_fr
set LANG=fr
.\celestia.exe
Once again, I got no error, but no french word either... Celestia ran correctly, but the text overlay was still in english...

GlobeMaker wrote:Hello Vincent,
When you do everything right, but the compilation fails, try this : delete all object files. Some bad .obj files stay in the directory. From the command line in the /src/ directory use the command :
del *.obj /S
Then compile again.
Hello Alan,
I often use the "del *.obj /S" command from the src folder before compiling. But in may case, Celestia compiles fine. The problem is that I can't have it translated...
@+
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

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #27by Christophe » 02.02.2006, 16:40

Vincent, it's fr_FR, not fr.
Christophe

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

Post #28by Vincent » 02.02.2006, 16:43

I also tried with fr_FR... with the same result.
@+
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

GlobeMaker
Posts: 216
Joined: 30.10.2005
With us: 19 years

Post #29by GlobeMaker » 02.02.2006, 19:40

There are two files you can edit to spell words in your language. :
C:\CVS3\celestia\src\celestia\res\celestia.rc
C:\CVS3\celestia\src\celestia\celestiacore.cpp

_________________________________________________

The first file makes words for the menus :
C:\CVS3\celestia\src\celestia\res\celestia.rc

POPUP "&Navigation"
BEGIN
MENUITEM "Select &Sol\tH", ID_NAVIGATION_HOME
MENUITEM "Tour G&uide...", ID_NAVIGATION_TOURGUIDE
MENUITEM "Select &Object...", ID_NAVIGATION_SELECT
MENUITEM "Goto Object...", ID_NAVIGATION_GOTO_OBJECT

______________________________________________

The second file paints words over the stars and planets :
C:\CVS3\celestia\src\celestia\celestiacore.cpp

case 'F':
addToHistory();
flash(_("Follow"));
sim->follow();
break;
Your wish is my command line.

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #30by Christophe » 02.02.2006, 22:44

Probably the first thing I would check is if the final executable is correctly linked against the iconv and intl libs.

If it is, then I would run a trace to see if it tries to open a celestia.mo file and where it looks for it.

But I have no idea how to do this under Windows.
Christophe

georgiouk
Posts: 47
Joined: 02.05.2005
With us: 19 years 6 months
Location: Greece

Post #31by georgiouk » 03.02.2006, 10:21

Hi to all.
Someone advised me sth that I really hope would be the solution
for you also Vincent.
My problem was that the changes I was making in the
celestiacore.cpp ( replacing for instance the word "travelling" below in
*overlay << _("Travelling "); (line 3158)
with the greek one) were not dispayed in the Celestia
due to the fact that the greek were not in unicode.
So we are trying now to create a function placed in
celestia\src\celutil\utf8.cpp that will
return the greek unicode value given a greek ISO-8859-7 character.

I really hope this info helps you Vincent :wink: .
K.G.

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

Post #32by Vincent » 04.02.2006, 14:12

Alan,

Thanks, I already made a french version "by hand". By the way, you have to edit 2 more files :

1- ...\src\celestia\winmain.cpp
> To translate the text in the dialog box you get when you right click on an object :
...
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "Aller voir");
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "Suivre");
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_SYNCORBIT, "Orbit Sync");
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Infos");
...
> To translate "loading: " that is displayed with the splashscreen :
...
splash->setMessage(string("Chargement : ") + filename);
...

2- ...\src\celengine\galaxy.cpp
> To translate the Galaxy Type Info :
...
return sprintf(buf, _("Galaxie (type Hubble : %s)"), getType());
...


Georgiouk,

Thanks a lot for your help ! I understand what you mean. Tell me if you manage to do it.


Christophe,

I tried to check what you suggested in MinGW32, but I don't have the ltrace function... I think I'll wait for more Windows users to get involved in this translation project, since I really spent a lot of time with no significative result. For the moment, I still can use (and provide to windows users) my "handmade" french version. Thanks a lot for your help ! :D

By the way, it would be great if Chris (Laurel) could have a look at the UTF-8 encoding issue with the solar system browser... :wink:
@+
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

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #33by Christophe » 04.02.2006, 16:32

Sorry to hear this. I think you are really close to it now, since it compiles it can only be a minor issue. Have you thougt about changing util.h to have the _() macro defined correctly?

It's too bad that no windows programer can give you some help with this.
Christophe

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #34by Christophe » 04.02.2006, 16:55

Just a thought, it would be a good thing if you made your changes available as a patch. You can produce such a patch with cvs:

Code: Select all

cvs diff -u > celestia_i18n_win32.patch
Christophe

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

Post #35by Vincent » 05.02.2006, 16:07

Christophe wrote:Have you thougt about changing util.h to have the _() macro defined correctly?

Yes you can check this (and all the other changes I made) from the patch :
http://vincent.gian.club.fr/celestia/ce ... in32.patch
Last edited by Vincent on 06.02.2006, 20:25, edited 2 times 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
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #36by Vincent » 06.02.2006, 18:21

Christophe,

My previous patch was not complete since I didn't include the "gettext.h" file and the gettext macro in all files containing translatable strings.

Code: Select all

+#include "../../inc/gettext.h"
+#define _(string) gettext (string)


You can download the updated patch here : http://vincent.gian.club.fr/celestia/ce ... in32.patch
Last edited by Vincent on 06.02.2006, 20:24, 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

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #37by Christophe » 06.02.2006, 19:39

You don't need to change all files with translations. They all include util.h, you need make your changes there only.
Christophe

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

Post #38by Vincent » 06.02.2006, 20:00

I did that because I was getting an error (for example, with body.cpp) :

Code: Select all

body.cpp
body.cpp(80) : error C3861: 'gettext': identifier not found, even with argument-dependent lookup
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual C++ Toolkit 2003\
bin\nmake.exe"' : return code '0x2'
Stop.

I realize now that's because I only added the macro "#define _(string) gettext (string)" in util.h, and I could/should have added the "#include "../../inc/gettext.h" too...

The patch downloadable from my previous post has been upupdated.
@+
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

tech2000
Posts: 258
Joined: 14.02.2006
Age: 52
With us: 18 years 9 months
Location: Skepplanda, Sweden

Post #39by tech2000 » 14.02.2006, 18:12

Wouldn't it be possible to implement all languages in Celestia? and change the chosen language in the options?

Now that would be a really neat feature!

Am I to optimistic?

Best regards, Anders

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #40by Christophe » 14.02.2006, 19:32

No, you're not too optimistic. This is precisely what gettext does.
Christophe


Return to “Development”