Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / tools / locale-builder / CultureInfoEntry.cs
index fe621b0e5cb44e3fb0dd0ce913c7a69a2f0c0dc5..f03d93a8366fb4dbc91f2a7d5eab6877cbe99c72 100644 (file)
 
 using System;
 using System.Text;
+using System.Collections.Generic;
+using System.Globalization;
 
-namespace Mono.Tools.LocaleBuilder {
+namespace Mono.Tools.LocaleBuilder
+{
+       public class CultureInfoEntry : Entry
+       {
+               string language;
 
-        public class CultureInfoEntry : Entry {
+               public string Script;
+               public string Territory;
 
-               public static CultureInfoEntry ShallowCopy (CultureInfoEntry e)
+               public string EnglishName;
+               public string DisplayName;
+               public string NativeName;
+               public string ThreeLetterWindowsLanguageName;
+               public string TwoLetterISOLanguageName;
+               public string ThreeLetterISOLanguageName;
+               public string LCID;
+               public string ParentLcid;
+               public string SpecificLcid;
+               public RegionInfoEntry RegionInfoEntry;
+               public DateTimeFormatEntry DateTimeFormatEntry;
+               public NumberFormatEntry NumberFormatEntry;
+               public TextInfoEntry TextInfoEntry;
+               public int DateTimeIndex;
+               public int NumberIndex;
+               public string NativeCurrencyName;
+               public string NativeTerritoryName;
+               public string[] NativeCalendarNames = new string[Constants.NUM_CALENDARS];
+
+               public CalendarType CalendarType;
+               public GregorianCalendarTypes GregorianCalendarType;
+
+               public List<CultureInfoEntry> Children = new List<CultureInfoEntry> ();
+
+               public int Row;
+
+               public CultureInfoEntry ()
+               {
+                       DateTimeFormatEntry = new DateTimeFormatEntry ();
+                       NumberFormatEntry = new NumberFormatEntry ();
+               }
+
+               public string Language {
+                       get {
+                               return language;
+                       }
+                       set {
+                               language = value;
+                       }
+               }
+
+               public bool HasMissingLocale { get; set; }
+
+               public bool IsNeutral {
+                       get {
+                               return Territory == null;
+                       }
+               }
+
+               public string OriginalName { get; set; }
+
+               public CultureInfoEntry Parent { get; set; }
+
+               public string Name {
+                       get {
+                               string s = language;
+                               if (Script != null)
+                                       s = s + "-" + Script;
+                               if (Territory != null)
+                                       s = s + "-" + Territory;
+
+                               return s;
+                       }
+               }
+
+               public string GetExportName ()
+               {
+                       return OriginalName.Replace ('_', '-');
+               }
+
+               public override string ToString ()
+               {
+                       StringBuilder builder = new StringBuilder ();
+                       AppendTableRow (builder);
+                       return builder.ToString ();
+               }
+
+               public void AppendTableRow (StringBuilder builder)
+               {
+                       builder.Append ("\t{");
+                       builder.Append (LCID).Append (", ");
+                       builder.Append (ParentLcid).Append (", ");
+
+                       int calendar_type = (int) CalendarType;
+                       calendar_type <<= 8;
+                       if (CalendarType == CalendarType.Gregorian)
+                               calendar_type |= (int) GregorianCalendarType;
+
+                       builder.Append (calendar_type).Append (", ");
+                       builder.Append (RegionInfoEntry == null ? -1 : RegionInfoEntry.Index).Append (", ");
+                       builder.Append (EncodeStringIdx (GetExportName ())).Append (", ");
+                       builder.Append (EncodeStringIdx (EnglishName)).Append (", ");
+                       builder.Append (EncodeStringIdx (NativeName)).Append (", ");
+                       builder.Append (EncodeStringIdx (ThreeLetterWindowsLanguageName)).Append (", ");
+                       builder.Append (EncodeStringIdx (ThreeLetterISOLanguageName)).Append (", ");
+                       builder.Append (EncodeStringIdx (TwoLetterISOLanguageName)).Append (", ");
+                       builder.Append (EncodeStringIdx (Territory)).Append (", ");
+                       AppendNames (builder, NativeCalendarNames).Append (", ");
+                       builder.Append (DateTimeFormatEntry.Row).Append (", ");
+                       builder.Append (NumberFormatEntry.Row).Append (", ");
+                       builder.Append (TextInfoEntry.ToString ());
+                       builder.Append ('}');
+               }
+
+               private string ValuesString (int[] values)
                {
-                       return (CultureInfoEntry) e.MemberwiseClone ();
+                       StringBuilder builder = new StringBuilder ();
+                       builder.Append ('{');
+                       for (int i = 0; i < values.Length; i++) {
+                               builder.Append (values[i].ToString ());
+                               if (i + 1 < values.Length)
+                                       builder.Append (", ");
+                       }
+                       builder.Append ("}");
+                       return builder.ToString ();
                }
+       }
 
-                string language;
-
-                public string Territory;
-                public string EnglishName;
-                public string DisplayName;
-                public string NativeName;
-                public string IcuName;
-                public string Win3Lang;
-                public string ISO2Lang;
-                public string ISO3Lang;
-                public string Lcid;
-                public string ParentLcid;
-                public string SpecificLcid;
-                public int RegionId = -1;
-                public DateTimeFormatEntry DateTimeFormatEntry;
-                public NumberFormatEntry NumberFormatEntry;
-                public TextInfoEntry TextInfoEntry;
-                public int [] CalendarData = new int [5];
-                public int DateTimeIndex;
-                public int NumberIndex;
-                
-                
-                public int Row;
-
-                public CultureInfoEntry ()
-                {
-                        DateTimeFormatEntry = new DateTimeFormatEntry ();
-                        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.StartsWith ("zh") ? "zh" : Language) + "-" + Territory;
-                        }
-                }
-
-                public override string ToString ()
-                {
-                        StringBuilder builder = new StringBuilder ();
-                        AppendTableRow (builder);
-                        return builder.ToString ();
-                }
-
-                public void AppendTableRow (StringBuilder builder)
-                {
-                        builder.Append ("\t{");
-                        builder.AppendFormat ("{0}, {1}, {2}, {3}," +
-                                        "{4}, {5}, {6}, " +
-                                        "{7}, {8}, {9}, " +
-                                        "{10}, {11}, " +
-                                        "{12}, " +
-                                        "{13}, {14}, {15}",
-                                        Lcid, ParentLcid, SpecificLcid, RegionId,
-                                        EncodeStringIdx (Name), EncodeStringIdx (IcuName), EncodeStringIdx (EnglishName),
-                                        EncodeStringIdx (DisplayName), EncodeStringIdx (NativeName), EncodeStringIdx (Win3Lang),
-                                        EncodeStringIdx (ISO3Lang), EncodeStringIdx (ISO2Lang),
-                                        ValuesString (CalendarData),
-                                        DateTimeFormatEntry == null ? -1 : DateTimeFormatEntry.Row,
-                                        NumberFormatEntry == null ? -1 : NumberFormatEntry.Row,
-                                       TextInfoEntry.ToString ());
-                        builder.Append ('}');
-                }
-
-                private string ValuesString (int [] values)
-                {
-                        StringBuilder builder = new StringBuilder ();
-                        builder.Append ('{');
-                        for (int i=0; i<values.Length; i++) {
-                                builder.Append (values [i].ToString ());
-                                if (i+1 < values.Length)
-                                        builder.Append (", ");
-                        }
-                        builder.Append ("}");
-                        return builder.ToString ();
-                }
-        }
-        
 }