diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-05-12 16:20:09 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-05-12 16:20:09 +0400 |
commit | 0a6fc66b53ef7ce479a2de361cb7a9ac3e32d213 (patch) | |
tree | 752bf37abb8b3b712b2d178df077767b84c34ce0 /tools | |
parent | cce89fd60d8286d27079d656e8b1de3206e2fe2e (diff) |
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).
svn path=/trunk/mono/; revision=44432
Diffstat (limited to 'tools')
-rw-r--r-- | tools/locale-builder/ChangeLog | 10 | ||||
-rw-r--r-- | tools/locale-builder/CultureInfoEntry.cs | 14 | ||||
-rw-r--r-- | tools/locale-builder/Driver.cs | 42 | ||||
-rw-r--r-- | tools/locale-builder/Entry.cs | 2 | ||||
-rw-r--r-- | tools/locale-builder/Makefile.am | 2 |
5 files changed, 50 insertions, 20 deletions
diff --git a/tools/locale-builder/ChangeLog b/tools/locale-builder/ChangeLog index 293a069213d..94d86952cf6 100644 --- a/tools/locale-builder/ChangeLog +++ b/tools/locale-builder/ChangeLog @@ -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 diff --git a/tools/locale-builder/CultureInfoEntry.cs b/tools/locale-builder/CultureInfoEntry.cs index b6448e687aa..dc29a5e1f68 100644 --- a/tools/locale-builder/CultureInfoEntry.cs +++ b/tools/locale-builder/CultureInfoEntry.cs @@ -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; } } diff --git a/tools/locale-builder/Driver.cs b/tools/locale-builder/Driver.cs index a05d5c88ed3..9d1b2de2efa 100644 --- a/tools/locale-builder/Driver.cs +++ b/tools/locale-builder/Driver.cs @@ -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; diff --git a/tools/locale-builder/Entry.cs b/tools/locale-builder/Entry.cs index 07beccdb53e..a26f64c3338 100644 --- a/tools/locale-builder/Entry.cs +++ b/tools/locale-builder/Entry.cs @@ -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"; diff --git a/tools/locale-builder/Makefile.am b/tools/locale-builder/Makefile.am index 736054a799c..3bc4c7fda45 100644 --- a/tools/locale-builder/Makefile.am +++ b/tools/locale-builder/Makefile.am @@ -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: |