Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CultureInfoEntry.cs « locale-builder « tools - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4aefd7cc94365f129466085043ee72101054524f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//
// Mono.Tools.LocaleBuilder.CultureInfoEntry
//
// Author(s):
//  Jackson Harper (jackson@ximian.com)
//
// (C) 2004 Novell, Inc (http://www.novell.com)
//


using System;
using System.Text;
using System.Collections.Generic;
using System.Globalization;

namespace Mono.Tools.LocaleBuilder
{
	public class CultureInfoEntry : Entry
	{
		string language;

		public string Script;
		public string Territory;

		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 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)
		{
			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 ();
		}
	}

}