Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2002:
[Freeciv-Dev] set LANG if not set on windows
Home

[Freeciv-Dev] set LANG if not set on windows

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] set LANG if not set on windows
From: Andreas Kemnade <akemnade@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Apr 2002 20:30:57 +0200

This is a patch which is in the windows patch for 1.12.0 and should go
into cvs for the next release.
It sets LANG if it is not set from the windows user language.

Greetings
Andreas Kemnade
--- /usr/src/cvs/freeciv/common/shared.c        Thu Apr 11 20:38:07 2002
+++ common/shared.c     Wed Apr 24 20:25:57 2002
@@ -28,6 +28,10 @@
 #include <pwd.h>
 #endif
 
+#ifdef WIN32_NATIVE
+#include <windows.h>
+#endif
+
 #include "astring.h"
 #include "fcintl.h"
 #include "log.h"
@@ -775,6 +779,58 @@
 void init_nls(void)
 {
 #ifdef ENABLE_NLS
+#ifdef WIN32_NATIVE
+  /* set LANG by hand if it is not set*/
+  if (!getenv("LANG")) {
+    static char envstr[40];
+    char *langname;
+    LCID lcid;
+    lcid = GetUserDefaultLCID();
+    langname = NULL;
+    switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
+      {
+      case LANG_SPANISH:
+       langname = "es";
+       break;
+      case LANG_GERMAN:
+       langname = "de";
+       break;
+      case LANG_ENGLISH:
+       langname = "en";
+       break;
+      case LANG_FRENCH:
+       langname = "fr";
+       break;
+      case LANG_DUTCH:
+       langname = "nl";
+       break;
+      case LANG_POLISH:
+       langname = "pl";
+       break;
+      case LANG_HUNGARIAN:
+       langname = "hu";
+       break;
+      case LANG_NORWEGIAN:
+       langname = "no";
+       break;
+      case LANG_JAPANESE:
+       langname = "ja";
+       break;
+      case LANG_PORTUGUESE:
+       langname = "pt";
+       break;
+      case LANG_ROMANIAN:
+       langname = "ro";
+       break;
+      case LANG_RUSSIAN:
+       langname = "ru";
+       break;
+      }
+    my_snprintf(envstr, sizeof(envstr), "LANG=%s", langname);
+    putenv(envstr); 
+  }
+#endif
+
   (void) setlocale(LC_ALL, "");
   (void) bindtextdomain(PACKAGE, LOCALEDIR);
   (void) textdomain(PACKAGE);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] set LANG if not set on windows, Andreas Kemnade <=