Copied remotely
[mono.git] / tools / locale-builder / CultureInfoEntry.cs
1 //
2 // Mono.Tools.LocaleBuilder.CultureInfoEntry
3 //
4 // Author(s):
5 //  Jackson Harper (jackson@ximian.com)
6 //
7 // (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9
10
11 using System;
12 using System.Text;
13
14 namespace Mono.Tools.LocaleBuilder {
15
16         public class CultureInfoEntry : Entry {
17
18                 public string Language;
19                 public string Territory;
20                 public string EnglishName;
21                 public string DisplayName;
22                 public string NativeName;
23                 public string IcuName;
24                 public string Win3Lang;
25                 public string ISO2Lang;
26                 public string ISO3Lang;
27                 public string Lcid;
28                 public string ParentLcid;
29                 public string SpecificLcid;
30                 public DateTimeFormatEntry DateTimeFormatEntry;
31                 public NumberFormatEntry NumberFormatEntry;
32                 public TextInfoEntry TextInfoEntry;
33                 public int [] CalendarData = new int [5];
34                 public int DateTimeIndex;
35                 public int NumberIndex;
36                 
37                 
38                 public int Row;
39
40                 public CultureInfoEntry ()
41                 {
42                         DateTimeFormatEntry = new DateTimeFormatEntry ();
43                         NumberFormatEntry = new NumberFormatEntry ();
44                 }
45
46                 public string Name {
47                         get {
48                                 if (Territory == null)
49                                         return Language;
50                                 return Language + "-" + Territory;
51                         }
52                 }
53
54                 public override string ToString ()
55                 {
56                         StringBuilder builder = new StringBuilder ();
57                         AppendTableRow (builder);
58                         return builder.ToString ();
59                 }
60
61                 public void AppendTableRow (StringBuilder builder)
62                 {
63                         builder.Append ("\t{");
64                         builder.AppendFormat ("{0}, {1}, {2}, " +
65                                         "{3}, {4}, {5}, " +
66                                         "{6}, {7}, {8}, " +
67                                         "{9}, {10}, " +
68                                         "{11}, " +
69                                         "{12}, {13}, {14}",
70                                         Lcid, ParentLcid, SpecificLcid,
71                                         EncodeStringIdx (Name), EncodeStringIdx (IcuName), EncodeStringIdx (EnglishName),
72                                         EncodeStringIdx (DisplayName), EncodeStringIdx (NativeName), EncodeStringIdx (Win3Lang),
73                                         EncodeStringIdx (ISO3Lang), EncodeStringIdx (ISO2Lang),
74                                         ValuesString (CalendarData),
75                                         DateTimeFormatEntry == null ? -1 : DateTimeFormatEntry.Row,
76                                         NumberFormatEntry == null ? -1 : NumberFormatEntry.Row,
77                                         TextInfoEntry.ToString ());
78                         builder.Append ('}');
79                 }
80
81                 private string ValuesString (int [] values)
82                 {
83                         StringBuilder builder = new StringBuilder ();
84                         builder.Append ('{');
85                         for (int i=0; i<values.Length; i++) {
86                                 builder.Append (values [i].ToString ());
87                                 if (i+1 < values.Length)
88                                         builder.Append (", ");
89                         }
90                         builder.Append ("}");
91                         return builder.ToString ();
92                 }
93         }
94         
95 }
96