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.