2005-05-12 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 12 May 2005 12:20:09 +0000 (12:20 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 12 May 2005 12:20:09 +0000 (12:20 -0000)
* Entry.cs :
  build fix. Incorrectly allowed access to protected member.
* CultureInfoEntry.cs,
  Driver.cs :
  Handle language "zh-CHS" as special case, since there is no "zh".
* Makefile :
  use -debug+ instead of -g (convenient when verifying with csc).

svn path=/trunk/mono/; revision=44432

tools/locale-builder/ChangeLog
tools/locale-builder/CultureInfoEntry.cs
tools/locale-builder/Driver.cs
tools/locale-builder/Entry.cs
tools/locale-builder/Makefile.am

index 293a069213d0e3bb35b014daae5a8e852c392223..94d86952cf67af8b46d1af14d10b4037fb8f24fa 100644 (file)
@@ -1,3 +1,13 @@
+2005-05-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Entry.cs :
+         build fix. Incorrectly allowed access to protected member.
+       * CultureInfoEntry.cs,
+         Driver.cs :
+         Handle language "zh-CHS" as special case, since there is no "zh".
+       * Makefile :
+         use -debug+ instead of -g (convenient when verifying with csc).
+
 2005-02-17  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Driver.cs : set \n for writer's NewLine explicitly (otherwise it
index b6448e687aa92982462b16a955633ee48c1029c6..dc29a5e1f68a5676eb4f760b45a6886c70cc6a62 100644 (file)
@@ -15,7 +15,8 @@ namespace Mono.Tools.LocaleBuilder {
 
         public class CultureInfoEntry : Entry {
 
-                public string Language;
+                string language;
+
                 public string Territory;
                 public string EnglishName;
                 public string DisplayName;
@@ -43,11 +44,20 @@ namespace Mono.Tools.LocaleBuilder {
                         NumberFormatEntry = new NumberFormatEntry ();
                 }
 
+                public string Language {
+                        get {
+                                return language;
+                        }
+                        set {
+                                language = (value == "zh") ? "zh-CHS" : value;
+                        }
+                }
+
                 public string Name {
                         get {
                                 if (Territory == null)
                                         return Language;
-                                return Language + "-" + Territory;
+                                return (Language.StartsWith ("zh") ? "zh" : Language) + "-" + Territory;
                         }
                 }
 
index a05d5c88ed334f58899feae6138e78caf1240d77..9d1b2de2efa1ea1afa7c9470cf29c0404ca36830 100644 (file)
@@ -188,9 +188,14 @@ namespace Mono.Tools.LocaleBuilder {
                        return new XPathDocument (xtr);
                }
 
+               private string GetShortName (string lang)
+               {
+                       return lang == "zh-CHS" ? "zh" : lang;
+               }
+
                 private bool ParseLang (string lang)
                {
-                        XPathDocument doc = GetXPathDocument (Path.Combine ("langs", lang + ".xml"));
+                        XPathDocument doc = GetXPathDocument (Path.Combine ("langs", GetShortName (lang) + ".xml"));
                        XPathNavigator nav = doc.CreateNavigator ();
                         CultureInfoEntry ci = new CultureInfoEntry ();
                         string lang_type, terr_type;
@@ -203,17 +208,17 @@ namespace Mono.Tools.LocaleBuilder {
                         ci.Language = (lang_type == String.Empty ? null : lang_type);
                         ci.Territory = (terr_type == String.Empty ? null : terr_type);
 
-                       if (!LookupLcids (ci))
+                       if (!LookupLcids (ci, true))
                                 return false;
 
-                        doc = GetXPathDocument (Path.Combine ("langs", Lang + ".xml"));
+                        doc = GetXPathDocument (Path.Combine ("langs", GetShortName (Lang) + ".xml"));
                        nav = doc.CreateNavigator ();
                        ci.DisplayName = LookupFullName (ci, nav);
                         
                        if (Lang == "en") {
                                ci.EnglishName = ci.DisplayName;
                        } else {
-                               doc = GetXPathDocument (Path.Combine ("langs", Lang + ".xml"));
+                               doc = GetXPathDocument (Path.Combine ("langs", GetShortName (lang) + ".xml"));
                                nav = doc.CreateNavigator ();
                                ci.EnglishName = LookupFullName (ci, nav);
                        }
@@ -221,7 +226,7 @@ namespace Mono.Tools.LocaleBuilder {
                        if (ci.Language == Lang) {
                                ci.NativeName = ci.DisplayName;
                        } else {
-                               doc = GetXPathDocument (Path.Combine ("langs", lang + ".xml"));
+                               doc = GetXPathDocument (Path.Combine ("langs", GetShortName (lang) + ".xml"));
                                nav = doc.CreateNavigator ();
                                ci.NativeName = LookupFullName (ci, nav);
                        }
@@ -266,7 +271,7 @@ namespace Mono.Tools.LocaleBuilder {
                        ci.Language = nav.Evaluate ("string (ldml/identity/language/@type)").ToString ();
                        ci.Territory = nav.Evaluate ("string (ldml/identity/territory/@type)").ToString ();
 
-                        if (!LookupLcids (ci))
+                        if (!LookupLcids (ci, false))
                                 return null;
                        LookupNames (ci);
 
@@ -287,7 +292,7 @@ namespace Mono.Tools.LocaleBuilder {
                         nav = doc.CreateNavigator ();
                         Lookup (nav, ci);
 
-                       doc = GetXPathDocument (Path.Combine ("langs", ci.Language + ".xml"));
+                       doc = GetXPathDocument (Path.Combine ("langs", GetShortName (ci.Language) + ".xml"));
                        nav = doc.CreateNavigator ();
                        Lookup (nav, ci);
 
@@ -320,7 +325,7 @@ namespace Mono.Tools.LocaleBuilder {
 
                private void LookupNames (CultureInfoEntry ci)
                {
-                       XPathDocument doc = GetXPathDocument (Path.Combine ("langs", Lang + ".xml"));
+                       XPathDocument doc = GetXPathDocument (Path.Combine ("langs", GetShortName (Lang) + ".xml"));
                        XPathNavigator nav = doc.CreateNavigator ();
 
                        ci.DisplayName = LookupFullName (ci, nav);
@@ -336,7 +341,7 @@ namespace Mono.Tools.LocaleBuilder {
                        if (ci.Language == Lang) {
                                ci.NativeName = ci.DisplayName;
                        } else {
-                               doc = GetXPathDocument (Path.Combine ("langs", ci.Language + ".xml"));
+                               doc = GetXPathDocument (Path.Combine ("langs", GetShortName (ci.Language) + ".xml"));
                                nav = doc.CreateNavigator ();
                                ci.NativeName = LookupFullName (ci, nav);
                        }
@@ -814,25 +819,30 @@ namespace Mono.Tools.LocaleBuilder {
                                 ci.NumberFormatEntry.CurrencySymbol = cur;
                 }
 
-               private bool LookupLcids (CultureInfoEntry ci)
+               private bool LookupLcids (CultureInfoEntry ci, bool lang)
                {
                        XPathDocument doc = GetXPathDocument ("lcids.xml");
                        XPathNavigator nav = doc.CreateNavigator ();
-                       string name = ci.Language;
+                       string name = ci.Name;
+                       // Language name does not always consist of locale name.
+                       // (for zh-* it must be either zh-CHS or zh-CHT)
+                       string langName = ci.Language;
 
-                        if (ci.Territory != null)
-                                name += "-" + ci.Territory;
+//                        if (ci.Territory != null)
+//                                name += "-" + ci.Territory;
 
                        XPathNodeIterator ni =(XPathNodeIterator) nav.Evaluate ("lcids/lcid[@name='"
-                                       + name + "']");
+                                       + (lang ? langName : name) + "']");
                        if (!ni.MoveNext ()) {
+                               Console.WriteLine ("no lcid found for: {0} ({1}/{2})", name, ci.Language, ci.Territory);
                                 string file;
+
                                 if (ci.Territory != null) {
                                         file = Path.Combine ("locales", ci.Language + "_" + ci.Territory + ".xml");
                                         File.Delete (file);
                                         Console.WriteLine ("deleting file:  " + file);
                                 }
-                               Console.WriteLine ("no lcid found for:  " + name);
+
                                return false;
                        }
 
@@ -864,7 +874,7 @@ namespace Mono.Tools.LocaleBuilder {
                        string ret;
 
                        ret = (string) nav.Evaluate ("string("+
-                                       pre + "languages/language[@type='" + ci.Language + "'])");
+                                       pre + "languages/language[@type='" + GetShortName (ci.Language) + "'])");
 
                        if (ci.Territory == null)
                                return ret;
index 07beccdb53e307c87b0d278f06fc71758e56252a..a26f64c33387a99996cd667701b8cc122a1f5cc8 100644 (file)
@@ -49,7 +49,7 @@ namespace Mono.Tools.LocaleBuilder {
                        }
                }
 
-                protected static String EncodeStringIdx (string str)
+                internal static String EncodeStringIdx (string str)
                 {
                         if (str == null)
                                 return "0";
index 736054a799ceb51f02ee480631cd13bdeb0bba2a..3bc4c7fda45145d29cecf43189683d70065b835d 100644 (file)
@@ -1,7 +1,7 @@
 
 MCS = mcs
 RUNTIME = mono
-MCSFLAGS = -g
+MCSFLAGS = -debug+
 # To build a reduced mono runtime with support only for some locales, # run:
 #      make minimal
 # To build with a single locale (en_US), run: