Skip to content

Commit

Permalink
2005-05-12 Atsushi Enomoto <[email protected]>
Browse files Browse the repository at this point in the history
	* 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
  • Loading branch information
atsushieno committed May 12, 2005
1 parent cce89fd commit 0a6fc66
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 20 deletions.
10 changes: 10 additions & 0 deletions tools/locale-builder/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 12 additions & 2 deletions tools/locale-builder/CultureInfoEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,11 +44,20 @@ public CultureInfoEntry ()
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;
}
}

Expand Down
42 changes: 26 additions & 16 deletions tools/locale-builder/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ private XPathDocument GetXPathDocument (string path)
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;
Expand All @@ -203,25 +208,25 @@ private bool ParseLang (string lang)
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);
}

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);
}
Expand Down Expand Up @@ -266,7 +271,7 @@ private CultureInfoEntry LookupCulture (string locale)
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);

Expand All @@ -287,7 +292,7 @@ private CultureInfoEntry LookupCulture (string locale)
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);

Expand Down Expand Up @@ -320,7 +325,7 @@ private void Lookup (XPathNavigator nav, CultureInfoEntry ci)

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);
Expand All @@ -336,7 +341,7 @@ private void LookupNames (CultureInfoEntry ci)
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);
}
Expand Down Expand Up @@ -814,25 +819,30 @@ private void LookupCurrencySymbol (XPathNavigator nav, CultureInfoEntry ci)
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;
}

Expand Down Expand Up @@ -864,7 +874,7 @@ private string LookupFullName (CultureInfoEntry ci, XPathNavigator nav)
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;
Expand Down
2 changes: 1 addition & 1 deletion tools/locale-builder/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int AddString (string s, int size) {
}
}

protected static String EncodeStringIdx (string str)
internal static String EncodeStringIdx (string str)
{
if (str == null)
return "0";
Expand Down
2 changes: 1 addition & 1 deletion tools/locale-builder/Makefile.am
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 0a6fc66

Please sign in to comment.