]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Work around mono-0.29 CurrentUICulture bug.
authorBruno Haible <bruno@clisp.org>
Tue, 13 Jan 2004 12:17:17 +0000 (12:17 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:37 +0000 (12:11 +0200)
gettext-tools/examples/ChangeLog
gettext-tools/examples/hello-csharp-forms/hello.cs
gettext-tools/examples/hello-csharp/hello.cs
gettext-tools/tests/ChangeLog
gettext-tools/tests/lang-csharp

index 12a66deda018eb13891fea023bf041556e539a91..7afe8a4dfe80303d09b3128b56dd7e2611beb6cb 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-10  Bruno Haible  <bruno@clisp.org>
+
+       * hello-csharp/hello.cs: Work around mono-0.29 CurrentUICulture bug.
+       * hello-csharp-forms/hello.cs: Likewise.
+
 2003-12-29  Bruno Haible  <bruno@clisp.org>
 
        * hello-perl/INSTALL: Mention that libintl-perl-1.09 required.
index ed8568cafb740a7356467bcda703f2db8c130eeb..bb344fb674acd854a4c9343fd02bacc69105ff8c 100644 (file)
@@ -1,5 +1,5 @@
 // Example for use of GNU gettext.
-// Copyright (C) 2003 Free Software Foundation, Inc.
+// Copyright (C) 2003-2004 Free Software Foundation, Inc.
 // This file is in the public domain.
 //
 // Source code of the C#/Forms program.
@@ -77,6 +77,20 @@ public class Hello {
   }
 
   public static void Main () {
+    #if __MonoCS__
+    // Some systems don't set CurrentCulture and CurrentUICulture as specified
+    // by LC_ALL. So set it by hand.
+    String locale = System.Environment.GetEnvironmentVariable("LC_ALL");
+    if (locale == null || locale == "")
+      locale = System.Environment.GetEnvironmentVariable("LANG");
+    if (!(locale == null || locale == "")) {
+      if (locale.IndexOf('.') >= 0)
+        locale = locale.Substring(0,locale.IndexOf('.'));
+      System.Threading.Thread.CurrentThread.CurrentCulture =
+      System.Threading.Thread.CurrentThread.CurrentUICulture =
+        new System.Globalization.CultureInfo(locale.Replace('_','-'));
+    }
+    #endif
     Application.Run(new HelloWindow());
   }
 }
index 1454990b654a0372f078aa78efce8e104e5f5fca..ce3c3b8cf7f32558f97edbe33d3fab33c5ccc826 100644 (file)
@@ -1,5 +1,5 @@
 // Example for use of GNU gettext.
-// Copyright (C) 2003 Free Software Foundation, Inc.
+// Copyright (C) 2003-2004 Free Software Foundation, Inc.
 // This file is in the public domain.
 //
 // Source code of the C# program.
@@ -10,6 +10,20 @@ using System.Diagnostics; /* Process */
 
 public class Hello {
   public static void Main (String[] args) {
+    #if __MonoCS__
+    // Some systems don't set CurrentCulture and CurrentUICulture as specified
+    // by LC_ALL. So set it by hand.
+    String locale = System.Environment.GetEnvironmentVariable("LC_ALL");
+    if (locale == null || locale == "")
+      locale = System.Environment.GetEnvironmentVariable("LANG");
+    if (!(locale == null || locale == "")) {
+      if (locale.IndexOf('.') >= 0)
+        locale = locale.Substring(0,locale.IndexOf('.'));
+      System.Threading.Thread.CurrentThread.CurrentCulture =
+      System.Threading.Thread.CurrentThread.CurrentUICulture =
+        new System.Globalization.CultureInfo(locale.Replace('_','-'));
+    }
+    #endif
     GettextResourceManager catalog =
       new GettextResourceManager("hello-csharp");
     Console.WriteLine(catalog.GetString("Hello, world!"));
index e943097aee4b5207ecb1c4605a7dcd54eca991cc..28ad914c55e2d10037e79495b5fa538827658b7e 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-10  Bruno Haible  <bruno@clisp.org>
+
+       * lang-csharp: Work around mono-0.29 CurrentUICulture bug.
+
 2003-12-29  Bruno Haible  <bruno@clisp.org>
 
        * testlocale.c: Include stdlib.h.
index e05cc2fbff25847dfe0f057c6ad5cecd6af5e03a..424c7fc49e0d950d6e5e353c8804706db0608601 100755 (executable)
@@ -5,7 +5,8 @@
 # Assumes the following packages are installed: pnet, pnetlib.
 
 # Note: This test fails with mono-0.28 because the CultureInfo.Parent pointers
-# are wrong for locales containing a language and a territory.
+# are wrong for locales containing a language and a territory. This is fixed
+# in mono-0.29.
 
 tmpfiles=""
 trap 'rm -fr $tmpfiles' 1 2 3 15
@@ -19,13 +20,13 @@ using System;
 using GNU.Gettext;
 class Program {
   static void Main (String[] args) {
-#if not_yet_needed
+    #if __MonoCS__
     // Some systems don't set CurrentCulture and CurrentUICulture as specified
     // by LC_ALL. So set it by hand.
     System.Threading.Thread.CurrentThread.CurrentCulture =
     System.Threading.Thread.CurrentThread.CurrentUICulture =
       new System.Globalization.CultureInfo("fr-FR");
-#endif
+    #endif
     int n = Int32.Parse(args[0]);
     GettextResourceManager catalog = new GettextResourceManager("prog");
     Console.WriteLine(catalog.GetString("'Your command, please?', asked the waiter."));