In Windows locale is not set in POL core - plus possible fix

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Post Reply
OWHorus
Grandmaster Poster
Posts: 105
Joined: Sat Feb 04, 2006 1:24 pm
Location: Vienna, Austria

In Windows locale is not set in POL core - plus possible fix

Post by OWHorus »

Hello,

in several new menus I use the StrFormatTime() script function. Since our game server is in German, we would like to use German dates. According to documentation the function should inherit the OS setting, but this does not work.

Example: I use date format string "%A, den %d. %B %Y". This gives <day of week>, den <day>. <monthname> <year>

In German this would be for example Samstag, den 24. Dezember 2011. But despite using a German version of Win XP to test it, it gives the output Saturday, den 24.December 2011.

Possible fix:
Use the function setlocale(LC_ALL, "") somewhere to set the programs locale (from MS documentation, sets the programs locale to the systems locale).
The constant LC_ALL is defined in locale.h, which also is not included.

I tried to include <locale.h> in pol.cpp, around line 60:

Code: Select all

#ifdef _WIN32
#include <process.h>
#include <locale.h>
#endif
inside a #ifdef _WIN32 clause as shown above.
Then I inserted the call to setlocale() here (pol.cpp, around line 2040 in function xmain_inner):

Code: Select all

int xmain_inner( int argc, char *argv[] )
{
#ifdef _WIN32
	MiniDumper::Initialize();
	// Aug. 15, 2006 Austin
	// Added atexit() call to remove the tray icon.
	atexit(ShutdownSystemTrayHandling);
	setlocale(LC_ALL,"");
#else
...
After recompiling the core, the date is now correct in german, using StrFormatTime().

I do not use the last core version (too much to do, sorry), and therefore did not make a patch for the source. On my machine it compiles with no (additional) errors or warnings (MS Visual C++ Express 2008) and works normally. For Linux/Unix compilation the changes should have no effect, since both are in _WIN32 clauses.

Hope this helps...

OWHorus
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: In Windows locale is not set in POL core - plus possible

Post by Turley »

Thx for the input. I will take a look at it tomorrow. I think it doesn't hurt if its also for Linux. And of cause frohes Fest :P
OWHorus
Grandmaster Poster
Posts: 105
Joined: Sat Feb 04, 2006 1:24 pm
Location: Vienna, Austria

Re: In Windows locale is not set in POL core - plus possible

Post by OWHorus »

Hallo Turley,

Dir auch Frohe Weihnachten! :D

OWHorus
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: In Windows locale is not set in POL core - plus possible

Post by Turley »

Grad volltrunken von weihnachtsmarkt zurück ja weihnachten wird schön :P marry Christmas everyone :P
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: In Windows locale is not set in POL core - plus possible

Post by Turley »

Added, thx again
Post Reply