Internationalization under Windows...

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 5 months
Location: Nancy, France

Internationalization under Windows...

Post #1by Vincent » 25.01.2006, 13:03

I'm trying to compile a french version of Celestia under Windows using gettext. Since nobody seems to have managed to do it yet, I suggest we centralize all information about our different tries to compile Celestia in other languages (=LANG) under Windows in this topic...

I go first :
1- I've installed gettext using the gettext-0.11.5-2003.02.01-1.exe installation file from the MinGW website : http://www.mingw.org/download.shtml
2- I've copied the "C:\mingw\include\libintl.h" file and pasted it into my "C:\MyCelestia\inc" folder
3- I've added this link in celestiacore.h : '#include <libintl.h>'
4- I've added this declaration line in celestiacore.cpp : '#define _(String) gettext (String)' (I know I'll have to add this line in all other files that contains strings to be translated...)
5- I've replaced the locale declaration 'setlocale(LC_ALL, "");' in glutmain.cpp and main.cpp with 'setlocale(LC_ALL, "fr");'
6- I've copied the "C:\MyCelestia\po\fr.po" file and pasted it into my "C:\MyCelestia\src\celestia\kde\po" folder
7- I compiled Celestia with MS SDK and MS Visual C++ Toolkit 2003

I opened Celestia, but still couldn't see any french word in it...
@+
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

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Post #2by Chuft-Captain » 25.01.2006, 13:40

Hi Vincent,

You might like to refer to this thread: http://celestiaproject.net/forum/viewtopic.php ... highlight=

in particular the links that ElChristou provides.

Regards
Phil
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

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

Post #3by Vincent » 25.01.2006, 13:53

Phil,

Thanks for the link. I've already had a look at Christophe's website, but I couldn't find any information about how to integrate gettext and the .po files in Celestia. I think it mostly explains how to build the .po files, i.e., 'the Translator's view'. What we actually need on windows is a good tutorial about how to integrate and use these files.
But maybe I missed something...
@+
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

Avatar
Adirondack M
Posts: 528
Joined: 01.03.2004
With us: 20 years 4 months

Post #4by Adirondack » 25.01.2006, 15:12

I did the localization of my german-speaking GUI (WIN32) by handwork. That's time consuming but it works better than any additional software solutions.

http://www.celestiamotherlode.net/catalog/utilities.html -> Localization

Adirondack
We all live under the same sky, but we do not have the same horizon. (K. Adenauer)
The horizon of some people is a circle with the radius zero - and they call it their point of view. (A. Einstein)

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

Post #5by Vincent » 25.01.2006, 15:33

Adirondack,

I made a french version by hand too, and I completely agree with you : it's a lot of work! :wink: But I still have an issue concerning the accentuated characters. For example, when I replace "Venus" by "Vnus", the "" is correctly displayed in the Solar System menu, but not in the "Selection Info" Overlay on the top left corner where it is displayed as "Vnus"... I've tried to change the locale using 'setlocale(LC_ALL, "fr", "FR", "FR_fr");', but it didn't work...

Moreover, I'm trying to use gettext not to have to do the work again for each new release...

Thanks.
@+
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: 21 years 11 months
Location: Lyon (France)

Re: Internationalization under Windows...

Post #6by Christophe » 25.01.2006, 16:07

Vincent wrote:3- I've added this link in celestiacore.h : '#include <libintl.h>'
4- I've added this declaration line in celestiacore.cpp : '#define _(String) gettext (String)' (I know I'll have to add this line in all other files that contains strings to be translated...)

No need to do this, all you have to do is change celutil/util.h.

Ditto for #include <libintl.h>, add it to util.h in an #ifdef _WIN32

If you want your changes to be included in the official Celestia distribution, you have to be careful not to break anything for the other platforms.

Vincent wrote:5- I've replaced the locale declaration 'setlocale(LC_ALL, "");' in glutmain.cpp and main.cpp with 'setlocale(LC_ALL, "fr");'

No need to do this, setlocale(LC_ALL, "") sets LC_ALL to the current value of the LC_ALL environment variable. The best would be to modify winmain.cpp to set this variable based on the Windows specific locale setting.

It's winmain.cpp you need to alter, not main.cpp nor glutmain.cpp, these aren't used for the Win32 interface (except if you want to build the GTK interface, but I don't think that's what you want).

Add somewhere in main():

Code: Select all

        /* here some code to set LC_ALL according to the Windows locale */

        setlocale(LC_NUMERIC, "C");
        setlocale(LC_ALL, "");

        #ifdef GETTEXT
        bindtextdomain(PACKAGE, LOCALEDIR);
        bind_textdomain_codeset(PACKAGE, "UTF-8");
        textdomain(PACKAGE);
        #endif /* GETTEXT */


You'll also need to alter the build system to define the GETTEXT macro ( -DGETTEXT compiler option ), and to link against the gettext lib ( -lgettext linker option).

Vincent wrote:6- I've copied the "C:\MyCelestia\po\fr.po" file and pasted it into my "C:\MyCelestia\src\celestia\kde\po" folder

You'll also need to change the build system to compile and install the po files. For now you can do it manually. You compile the po files with the gmsgfmt tool which should be in the gettext package:

Code: Select all

gmsgfmt -o fr.gmo fr.po


Now, I don't know where gettext will look for the mo file, under linux fr.gmo gets installed as /usr/share/locale/fr/LC_MESSAGE/celestia.mo
Christophe

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

Post #7by Christophe » 25.01.2006, 21:30

The MinGW version of gettext is quite outdated. The official GNU Gettext now supports windows out of the box, no need for a port.

Precompiled binaries are available here.

The FAQ explains how to get it working on Windows.
Christophe

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

Post #8by Vincent » 25.01.2006, 21:40

Christophe,

I managed to compile the po file, but...
Christophe wrote:You'll also need to alter the build system to define the GETTEXT macro ( -DGETTEXT compiler option ), and to link against the gettext lib ( -lgettext linker option).
...since I'm not very familiar with programming terms, I would need some more help on this point...

Thanks Christophe.

Added 5 mn later : I wrote this post before I saw your last post... Thanks for the link.
@+
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 5 months
Location: Nancy, France

Post #9by Vincent » 26.01.2006, 11:28

I've not finished yet, but I found some very useful information about how to integrate GNU gettext in a distribution on Chapter 12 (The Maintainer's View) of the gettext manual site. So if someone else wants to give it a try, here's the link :
http://www.gnu.org/software/gettext/man ... ttext.html

Good luck !
Thanks again Christophe.
@+
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 5 months
Location: Nancy, France

Post #10by Vincent » 29.01.2006, 14:00

Christophe,

I put the fr.gmo file into my
"C:\Program Files\GnuWin32\share\locale\fr\LC_MESSAGES\celestia.mo" folder.

But here's what you can read in the GNU gettext FAQ :
you can also guess the .mo file's location: it 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).


These arguments (defined in the winmain.ccp file, as you suggested above) are "PACKAGE" and "LOCALEDIR"...

Do I have to modify these arguments so that Celestia finds the fr.gmo file ?? There's something I'm missing here...
@+
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: 21 years 11 months
Location: Lyon (France)

Post #11by Christophe » 29.01.2006, 18:06

PACKAGE is normaly defined as celestia, but I'm not sure that LOCALEDIR is properly defined under Windows.

You can try adding this to main() to check the values:

Code: Select all

std::cout << "PACKAGE: " << PACKAGE << std::endl;
std::cout << "LOCALEDIR: " << LOCALEDIR << std::endl;
Christophe

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

Post #12by Vincent » 29.01.2006, 19:28

I added these line in :

Code: Select all

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
...

But I couldn't compile. Here's the error I got :
d::ostream &,const StellarClass &)'
..\celengine\astro.h(129): or 'std::ostream &operator <<(std::ostream &,const astro::Date)'
C:\Program Files\Microsoft Visual C++ Toolkit 2003\include\ostream(880):
or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
...
@+
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

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

Post #13by georgiouk » 31.01.2006, 15:50

Hi to all.
I'm trying to compile a greek version of Celestia under Windows.
I have tried to create a greek .txf font files through this "converter"

http://celestia.teyssier.org/ttf2txf/index.html

and then placed them to celestia\fonts
and made the necessary changes to the celestia.cfg
but unfortunately still the greek characters "deny" to appear!

Notice: The menu displays greek characters by just adding the below code:

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ELL)
#ifdef _WIN32
LANGUAGE LANG_GREEK, SUBLANG_DEFAULT
#pragma code_page(1253)
#endif //_WIN32

So I 'll try Vincents way....
.......................................................
K.G

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

Post #14by Christophe » 31.01.2006, 16:38

As far as I know, the WGL4 character map already includes greek characters, see for example a preview of the sans font: Image.

Then to have Celestia actually display greek letters you have to patch the source (replacing english strings by their translations) or get gettext to work, or simply use translated data files (eg solarsys.ssc).
Christophe

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

Post #15by Vincent » 31.01.2006, 17:28

Christophe,

When I made a french version "by hand", I had an issue with accentuated characters. For example, when I replaced "Venus" with "V?©nus" in the solarsys.ssc, I had 2 options :
- When I saved the file with ANSI encoding, the Solar System dialog correctly displayed 'V?©nus', but Celestia's overlay function displayed 'Vus' on screen.
- When I saved the file with UTF-8 encoding, the Solar System dialog displayed 'V???©nus' while Celestia's overlay function correctly displayed 'V?©nus', on screen.

Do you have any explanation/clue ? 8O

Georgiouk,

I'm really happy you're also trying to integrate Gettext in Celestia because it's very not an easy task and I started to feel a little bit alone on this project... :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: 21 years 11 months
Location: Lyon (France)

Post #16by Christophe » 31.01.2006, 19:42

Normaly data files are supposed to be in UTF-8. This works as expected under Linux, if it doesn't under Windows then it's a bug!

Note that you can also use unicode escapes in data files (e.g. \u20AC for the Euro symbol ?‚¬).
Christophe

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

Post #17by Vincent » 31.01.2006, 19:48

I used to use unicode escapes both in scripts and in data files. But unfortunately, I had the same problem when displaying accentuated characters : when I wrote 'V\u00e9nus' in the solarsys.scc file, the Solar System dialog displayed 'V???©nus'.
Last edited by Vincent on 31.01.2006, 20:28, 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: 21 years 11 months
Location: Lyon (France)

Post #18by Christophe » 31.01.2006, 20:06

Obviously some adjustments will need to be made to the Windows source code to make it work with other languages. The solar system browser for example doesn't support the UTF-8 encoding of body names, and if gettext is enabled, it will display the internal (English) names instead of the translated ones.

I think that if you get gettext to work on Windows, Chris will be more than happy to fix the remaining issues.
Christophe

Sui Ota
Posts: 75
Joined: 05.10.2005
With us: 18 years 8 months
Location: Saitama, Japan

Post #19by Sui Ota » 01.02.2006, 09:35

Vincent wrote:- When I saved the file with ANSI encoding, the Solar System dialog correctly displayed 'V?©nus', but Celestia's overlay function displayed 'Vus' on screen.
- When I saved the file with UTF-8 encoding, the Solar System dialog displayed 'V???©nus' while Celestia's overlay function correctly displayed 'V?©nus', on screen.

I tried to translate Celestia into Japanese, and I encountered similar problem.
This problem occurs in alert dialog, too.
If this problem is solved, it will be great advancement for translation of Celestia.

-Sui

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

Post #20by Christophe » 01.02.2006, 11:06

Another option to get an internationalized version of Celestia under Windows would be to work on the GTK interface rather than the Win32 one.

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


Return to “Development”