Author: atsushi
Date: 2005-05-12 08:20:09 -0400 (Thu, 12 May 2005)
New Revision: 44432

Modified:
   trunk/mono/tools/locale-builder/ChangeLog
   trunk/mono/tools/locale-builder/CultureInfoEntry.cs
   trunk/mono/tools/locale-builder/Driver.cs
   trunk/mono/tools/locale-builder/Entry.cs
   trunk/mono/tools/locale-builder/Makefile.am
Log:
2005-05-12  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * 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).



Modified: trunk/mono/tools/locale-builder/ChangeLog
===================================================================
--- trunk/mono/tools/locale-builder/ChangeLog   2005-05-12 12:07:17 UTC (rev 
44431)
+++ trunk/mono/tools/locale-builder/ChangeLog   2005-05-12 12:20:09 UTC (rev 
44432)
@@ -1,3 +1,13 @@
+2005-05-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * Driver.cs : set \n for writer's NewLine explicitly (otherwise it

Modified: trunk/mono/tools/locale-builder/CultureInfoEntry.cs
===================================================================
--- trunk/mono/tools/locale-builder/CultureInfoEntry.cs 2005-05-12 12:07:17 UTC 
(rev 44431)
+++ trunk/mono/tools/locale-builder/CultureInfoEntry.cs 2005-05-12 12:20:09 UTC 
(rev 44432)
@@ -15,7 +15,8 @@
 
         public class CultureInfoEntry : Entry {
 
-                public string Language;
+                string language;
+
                 public string Territory;
                 public string EnglishName;
                 public string DisplayName;
@@ -43,11 +44,20 @@
                         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;
                         }
                 }
 

Modified: trunk/mono/tools/locale-builder/Driver.cs
===================================================================
--- trunk/mono/tools/locale-builder/Driver.cs   2005-05-12 12:07:17 UTC (rev 
44431)
+++ trunk/mono/tools/locale-builder/Driver.cs   2005-05-12 12:20:09 UTC (rev 
44432)
@@ -188,9 +188,14 @@
                        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 @@
                         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 @@
                        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 @@
                        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 @@
                         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 @@
 
                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 @@
                        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 @@
                                 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/[EMAIL PROTECTED]'"
-                                       + 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 @@
                        string ret;
 
                        ret = (string) nav.Evaluate ("string("+
-                                       pre + "languages/[EMAIL PROTECTED]'" + 
ci.Language + "'])");
+                                       pre + "languages/[EMAIL PROTECTED]'" + 
GetShortName (ci.Language) + "'])");
 
                        if (ci.Territory == null)
                                return ret;

Modified: trunk/mono/tools/locale-builder/Entry.cs
===================================================================
--- trunk/mono/tools/locale-builder/Entry.cs    2005-05-12 12:07:17 UTC (rev 
44431)
+++ trunk/mono/tools/locale-builder/Entry.cs    2005-05-12 12:20:09 UTC (rev 
44432)
@@ -49,7 +49,7 @@
                        }
                }
 
-                protected static String EncodeStringIdx (string str)
+                internal static String EncodeStringIdx (string str)
                 {
                         if (str == null)
                                 return "0";

Modified: trunk/mono/tools/locale-builder/Makefile.am
===================================================================
--- trunk/mono/tools/locale-builder/Makefile.am 2005-05-12 12:07:17 UTC (rev 
44431)
+++ trunk/mono/tools/locale-builder/Makefile.am 2005-05-12 12:20:09 UTC (rev 
44432)
@@ -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:

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to