forked from globalizejs/globalize
/
Program.cs
594 lines (546 loc) · 27.7 KB
/
Program.cs
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using System.Web.Script.Serialization;
using System.Collections.Specialized;
using System.Collections;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Diagnostics;
using Microsoft.Ajax.Utilities;
namespace Globalization {
public class GlobalizationInfo {
public string name = "";
public string englishName;
public string nativeName;
public string language;
public bool isRTL;
public NumberFormatInfo numberFormat;
public Dictionary<String, DateFormatInfo> calendars;
private CultureInfo culture;
public static Dictionary<String, Object> InvariantGlobInfo;
private static string[] _numberNegativePatterns = "(n)|-n|- n|n-|n -".Split('|');
private static string[] _currencyNegativePatterns = "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)".Split('|');
private static string[] _percentNegativePatterns = "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %".Split('|');
private static string[] _currencyPositivePatterns = "$n|n$|$ n|n $".Split('|');
private static string[] _percentPositivePatterns = "n %|n%|%n|% n".Split('|');
public static GlobalizationInfo GetGlobInfo(CultureInfo culture) {
var info = new GlobalizationInfo {
culture = culture,
language = (culture == CultureInfo.InvariantCulture || culture.IsNeutralCulture) ? culture.Name : culture.Parent.Name,
name = String.IsNullOrEmpty(culture.Name) ? "invariant" : culture.Name,
englishName = String.IsNullOrEmpty(culture.Name) ? "invariant" : culture.EnglishName,
nativeName = String.IsNullOrEmpty(culture.Name) ? "invariant" : culture.NativeName,
isRTL = culture.TextInfo.IsRightToLeft,
numberFormat = GetNumberFormatInfo(culture),
calendars = GetCalendars(culture)
};
return info;
}
public static Dictionary<String, DateFormatInfo> GetCalendars(CultureInfo culture) {
var calendars = new Dictionary<String, DateFormatInfo>();
bool foundStandard = false;
var gregorianType = typeof(GregorianCalendar);
var defaultCalendar = culture.DateTimeFormat.Calendar;
var defaultCalendarType = defaultCalendar.GetType();
GregorianCalendarTypes? gregorianCalendarType = null;
if (defaultCalendarType == gregorianType) {
gregorianCalendarType = ((GregorianCalendar)defaultCalendar).CalendarType;
}
var optionalCalendars = culture.OptionalCalendars;
foreach (var calendar in optionalCalendars) {
var type = calendar.GetType();
string name;
bool isStandard = false;
if (type == gregorianType) {
var calendarType = ((GregorianCalendar)calendar).CalendarType;
if (calendarType == GregorianCalendarTypes.USEnglish) {
// we include the Gregorian_USEnglish culture as part of the Invariant culture
// because it is so common -- it is an optional calendar of every single english
// speaking culture. So, skip it when found for any other culture.
continue;
}
else if (culture == CultureInfo.InvariantCulture) {
// invariant has one calendar, Gregorian_Localized, which is identical
// to Gregorian_USEnglish. This one will take the place of any _USEnglish
// calendards found in other cultures.
name = " Gregorian_USEnglish";
}
else {
name = "Gregorian_" + calendarType.ToString();
}
if (!foundStandard && gregorianCalendarType.HasValue && gregorianCalendarType == gregorianCalendarType.Value) {
isStandard = true;
foundStandard = true;
}
}
else {
name = type.Name.Replace("Calendar", "");
if (!foundStandard) {
isStandard = true;
foundStandard = true;
}
}
string key = name;
if (isStandard) {
key = "standard";
}
if (culture != CultureInfo.InvariantCulture) {
culture.DateTimeFormat.Calendar = calendar;
}
var calendarInfo = GetDateTimeFormatInfo(culture, name);
calendars.Add(key, calendarInfo);
}
if (!foundStandard) {
throw new ApplicationException("Could not locate the standard calendar type for culture '" + culture.Name + "'.");
}
return calendars;
}
public static GlobalizationInfo.NumberFormatInfo GetNumberFormatInfo(CultureInfo culture) {
var nf = culture.NumberFormat;
return new GlobalizationInfo.NumberFormatInfo {
decimals = nf.NumberDecimalDigits,
decimalSeparator = nf.NumberDecimalSeparator,
groupSeparator = nf.NumberGroupSeparator,
groupSizes = nf.NumberGroupSizes,
negative = nf.NegativeSign,
positive = nf.PositiveSign,
pattern = new string[] { GetFromStringList(_numberNegativePatterns, nf.NumberNegativePattern) },
currency = new GlobalizationInfo.NumberFormatInfo.NumberClassFormatInfo {
decimals = nf.CurrencyDecimalDigits,
decimalSeparator = nf.CurrencyDecimalSeparator,
groupSeparator = nf.CurrencyGroupSeparator,
groupSizes = nf.CurrencyGroupSizes,
pattern = new string[] {
GetFromStringList(_currencyNegativePatterns, nf.CurrencyNegativePattern),
GetFromStringList(_currencyPositivePatterns, nf.CurrencyPositivePattern)
},
symbol = nf.CurrencySymbol
},
percent = new GlobalizationInfo.NumberFormatInfo.NumberClassFormatInfo {
decimals = nf.PercentDecimalDigits,
decimalSeparator = nf.PercentDecimalSeparator,
groupSeparator = nf.PercentGroupSeparator,
groupSizes = nf.PercentGroupSizes,
pattern = new string[] {
GetFromStringList(_percentNegativePatterns, nf.PercentNegativePattern),
GetFromStringList(_percentPositivePatterns, nf.PercentPositivePattern)
},
symbol = nf.PercentSymbol
}
};
}
public static string[] GetAMPMDesignators(CultureInfo culture, string ampm) {
return String.IsNullOrEmpty(ampm) ? null : new string[] { ampm, culture.TextInfo.ToLower(ampm), culture.TextInfo.ToUpper(ampm) };
}
public static GlobalizationInfo.DateFormatInfo GetDateTimeFormatInfo(CultureInfo culture, string calendarName) {
var df = culture.DateTimeFormat;
var info = new GlobalizationInfo.DateFormatInfo {
name = calendarName,
months = new DateFormatInfo.MonthInfo { names = df.MonthNames, namesAbbr = df.AbbreviatedMonthNames },
monthsGenitive = new DateFormatInfo.MonthInfo { names = df.MonthGenitiveNames, namesAbbr = df.AbbreviatedMonthGenitiveNames },
firstDay = (int) df.FirstDayOfWeek,
dateSeparator = df.DateSeparator,
timeSeparator = df.TimeSeparator,
days = new DateFormatInfo.DayInfo { names = df.DayNames, namesAbbr = df.AbbreviatedDayNames, namesShort = df.ShortestDayNames },
eras = GetEraInfo(culture),
twoDigitYearMax = df.Calendar.TwoDigitYearMax,
patterns = GetPatterns(df)
};
info.AM = GetAMPMDesignators(culture, df.AMDesignator);
info.PM = GetAMPMDesignators(culture, df.PMDesignator);
if (df.Calendar != null) {
var type = df.Calendar.GetType();
if (type == typeof(HijriCalendar)) {
string convert;
using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Generator.HijriCalendar.js"))) {
convert = sr.ReadToEnd();
}
int adjustment = ((HijriCalendar)df.Calendar).HijriAdjustment;
convert = convert.Replace("%HIJRIADJUSTMENT%", adjustment.ToString(CultureInfo.InvariantCulture));
info.convertScriptBlock = convert;
}
else if (type == typeof(UmAlQuraCalendar)) {
using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Generator.UmAlQuraCalendar.js"))) {
info.convertScriptBlock = sr.ReadToEnd();
}
}
}
return info;
}
private static GlobalizationInfo.DateFormatInfo.EraInfo[] GetEraInfo(CultureInfo culture) {
Calendar cal = culture.DateTimeFormat.Calendar;
List<GlobalizationInfo.DateFormatInfo.EraInfo> eras = null;
if (cal != null) {
eras = new List<GlobalizationInfo.DateFormatInfo.EraInfo>();
foreach (var eraNum in cal.Eras) {
eras.Add(GetEraInfo(culture, eraNum));
}
}
return eras == null ? null : eras.ToArray();
}
private static GlobalizationInfo.DateFormatInfo.EraInfo GetEraInfo(CultureInfo culture, int eraNum) {
var era = new GlobalizationInfo.DateFormatInfo.EraInfo {
name = culture.DateTimeFormat.GetEraName(eraNum),
offset = 0,
start = null
};
var calendar = culture.DateTimeFormat.Calendar;
Type type = calendar.GetType();
if (type != typeof(GregorianCalendar)) {
if (type == typeof(TaiwanCalendar)) {
era.offset = 0x777;
}
else if (type == typeof(KoreanCalendar)) {
era.offset = -2333;
}
else if (type == typeof(ThaiBuddhistCalendar)) {
era.offset = -543;
}
else if (type == typeof(JapaneseCalendar)) {
switch (eraNum) {
case 1:
era.start = 0xdf9984200L;
era.offset = 0x7c4;
break;
case 2:
era.start = -1357603200000L;
era.offset = 0x785;
break;
case 3:
era.start = -1812153600000L;
era.offset = 0x777;
break;
case 4:
era.start = null;
era.offset = 0x74b;
break;
default:
throw new InvalidOperationException("Invalid era number for JapaneseCalendar: " + eraNum.ToString());
}
}
}
return era;
}
private static Dictionary<String, String> GetPatterns(DateTimeFormatInfo df) {
var patterns = new Dictionary<String, String> {
{ "d", df.ShortDatePattern },
{ "D", df.LongDatePattern },
{ "t", df.ShortTimePattern },
{ "T", df.LongTimePattern },
{ "f", df.LongDatePattern + " " + df.ShortTimePattern },
{ "F", df.FullDateTimePattern },
{ "M", df.MonthDayPattern },
{ "S", df.SortableDateTimePattern },
{ "Y", df.YearMonthPattern }
};
return patterns;
}
private static bool ArrayEquality(Array arr1, Array arr2) {
if (arr1.Length == arr2.Length) {
for (int i = 0; i < arr1.Length; i++) {
if (!arr1.GetValue(i).Equals(arr2.GetValue(i))) {
return false;
}
}
return true;
}
return false;
}
private static bool ListEquality(IList arr1, IList arr2) {
if (arr1.Count == arr2.Count) {
for (int i = 0; i < arr1.Count; i++) {
var val1 = arr1[i];
var val2 = arr2[i];
if (val1 == null || !val1.Equals(val2)) {
if (val1 is IList && val2 is IList) {
if (!ListEquality(val1 as IList, val2 as IList)) {
return false;
}
}
else if (val1 is Dictionary<String, Object> && val2 is Dictionary<String, Object>) {
var diff = DiffGlobInfos((Dictionary<String, Object>)val1, (Dictionary<String, Object>)val2);
if (diff.Count > 0) {
return false;
}
}
else {
return false;
}
}
}
return true;
}
return false;
}
private static string GetFromStringList(string[] list, int value) {
return value < list.Length ? list[value] : null;
}
public Dictionary<String, Object> ToDictionary() {
var jss = new JavaScriptSerializer();
var str = jss.Serialize(this);
var dictionary = jss.Deserialize<Dictionary<String, Object>>(str);
var cals = (Dictionary<String, Object>) dictionary["calendars"];
Dictionary<String, Object> invariantStandardCal = null;
if (culture != CultureInfo.InvariantCulture) {
invariantStandardCal = (Dictionary<String, Object>)((Dictionary<String, Object>)GlobalizationInfo.InvariantGlobInfo["calendars"])["standard"];
foreach (var pair in this.calendars) {
var cal = (Dictionary<String, Object>)cals[pair.Key];
// make each calendar a diff from the standard invariant calendar
cals[pair.Key] = cal = DiffGlobInfos(invariantStandardCal, cal);
// apply convert script if it exists
if (!String.IsNullOrEmpty(pair.Value.convertScriptBlock)) {
cal["convert"] = pair.Value.convertScriptBlock;
}
// remove redundant monthsGenitive array if it is equivilent to months
Dictionary<String, Object> months = cal.ContainsKey("months") ? (Dictionary<String, Object>)cal["months"] : null;
Dictionary<String, Object> monthsGenitive = cal.ContainsKey("monthsGenitive") ? (Dictionary<String, Object>)cal["monthsGenitive"] : null;
Dictionary<String, Object> diff = (months != null && monthsGenitive != null) ? DiffGlobInfos(months, monthsGenitive) : null;
if (diff != null && diff.Count == 0) {
// the genitive months are the same as months, so remove it since it's optional
cal.Remove("monthsGenitive");
}
}
}
return dictionary;
}
public static string GenerateJavaScript(CultureInfo culture, string name, Dictionary<String, Object> dictionary, StringBuilder aggregateScript) {
string cultureFragment = ToJavaScript(culture, dictionary, 2, false);
if (aggregateScript != null) {
aggregateScript.AppendFormat(CultureInfo.InvariantCulture, @" culture = cultures[""{0}""] = $.extend(true, {{}}, invariant, {{
{1}
}}, cultures[""{0}""]);
culture.calendar = culture.calendars.standard;
", name, cultureFragment);
}
return string.Format(CultureInfo.InvariantCulture, @"(function($) {{
var cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard,
culture = cultures[""{0}""] = $.extend(true, {{}}, invariant, {{
{1}
}}, cultures[""{0}""]);
culture.calendar = culture.calendars.standard;
}})(jQuery);", name, cultureFragment);
}
private static string Serialize(object value) {
// no need to escape single quotes
return _jss.Serialize(value).Replace("\\u0027", "'");
}
private static string ToJavaScript(CultureInfo culture, Dictionary<String, Object> dictionary, int level, bool isCalendars) {
StringBuilder sb = new StringBuilder();
string padding = _padding.Substring(0, level * 4);
bool first = true;
foreach (var pair in dictionary) {
if (!first) {
sb.Append(",\n");
}
first = false;
if (pair.Value is Dictionary<String, Object>) {
if (culture != CultureInfo.InvariantCulture && isCalendars) {
sb.AppendFormat("{0}{1}: $.extend(true, {{}}, standard, {{\n{2}\n{0}}})", padding, pair.Key, ToJavaScript(culture, (Dictionary<String, Object>)pair.Value, level + 1, false));
}
else {
sb.AppendFormat("{0}{1}: {{\n{2}\n{0}}}", padding, pair.Key, ToJavaScript(culture, (Dictionary<String, Object>)pair.Value, level + 1, pair.Key.Equals("calendars")));
}
}
else if (pair.Key.Equals("convert")) {
sb.AppendFormat("{0}convert: {{\n{1}\n{0}}}", padding, pair.Value);
}
else if (pair.Key.Equals("groupSeparator")) {
sb.AppendFormat("{0}',': {1}", padding, Serialize(pair.Value));
}
else if (pair.Key.Equals("decimalSeparator")) {
sb.AppendFormat("{0}'.': {1}", padding, Serialize(pair.Value));
}
else if (pair.Key.Equals("positive")) {
sb.AppendFormat("{0}'+': {1}", padding, Serialize(pair.Value));
}
else if (pair.Key.Equals("negative")) {
sb.AppendFormat("{0}'-': {1}", padding, Serialize(pair.Value));
}
else if (pair.Key.Equals("dateSeparator")) {
sb.AppendFormat("{0}'/': {1}", padding, Serialize(pair.Value));
}
else if (pair.Key.Equals("timeSeparator")) {
sb.AppendFormat("{0}':': {1}", padding, Serialize(pair.Value));
}
else {
sb.AppendFormat("{0}{1}: {2}", padding, pair.Key, Serialize(pair.Value));
}
}
return sb.ToString();
}
private static JavaScriptSerializer _jss = new JavaScriptSerializer();
private static string _padding = " ";
private static Dictionary<String, Object> ToDictionary(IEnumerable<KeyValuePair<String, Object>> pairs) {
var d = new Dictionary<String, Object>();
foreach (var pair in pairs) {
d.Add(pair.Key, pair.Value);
}
return d;
}
public static Dictionary<String, Object> DiffGlobInfos(Dictionary<String, Object> glob1, Dictionary<String, Object> glob2) {
var unique = new Dictionary<String, Object>();
var comparer = new KeyValueComparer();
var diff = ToDictionary(glob2.Except(glob1, comparer));
foreach (var pair in glob2) {
if (diff.ContainsKey(pair.Key) && pair.Value != null) {
if (pair.Value is Dictionary<String, Object>) {
var subdiff = glob1.ContainsKey(pair.Key) ? DiffGlobInfos((Dictionary<String, Object>)glob1[pair.Key], (Dictionary<String, Object>)pair.Value) : (Dictionary<String, Object>)pair.Value;
if (subdiff.Count > 0) {
//Debug.WriteLine("Replacing\n {0}\nwith\n {1}", _jss.Serialize(diff[pair.Key]), _jss.Serialize(subdiff));
diff[pair.Key] = subdiff;
}
else {
//Debug.WriteLine("\nRemoving {0}\n", _jss.Serialize(pair.Key));
diff.Remove(pair.Key);
}
}
else if (pair.Value is IList) {
if (glob1.ContainsKey(pair.Key) && ListEquality((IList)pair.Value, (IList)glob1[pair.Key])) {
diff.Remove(pair.Key);
}
}
}
}
return diff;
}
public class KeyValueComparer : IEqualityComparer<KeyValuePair<String, Object>> {
public bool Equals(KeyValuePair<String, Object> x, KeyValuePair<String, Object> y) {
if (x.Key.Equals(y.Key)) {
if ((x.Value == null && y.Value == null) || (x.Value != null && x.Value.Equals(y.Value))) {
return true;
}
else if (x.Value is ArrayList && y.Value is ArrayList) {
return ListEquality((IList)x.Value, (IList)y.Value);
}
else if (x.Value is Array && y.Value is Array) {
return ArrayEquality(x.Value as Array, y.Value as Array);
}
else if (x.Value is Dictionary<String, Object> && y.Value is Dictionary<String, Object>) {
var diff = DiffGlobInfos((Dictionary<String, Object>)x.Value, (Dictionary<String, Object>)y.Value);
if (diff.Count == 0) {
return true;
}
//else {
// Debug.WriteLine(" Dictionaries diff:\n {0}\n {1}", _jss.Serialize(x.Value), _jss.Serialize(y.Value));
//}
}
}
//Debug.WriteLine(" Diff found: {0}={1}, {2}={3}", x.Key, x.Value, y.Key, y.Value);
return false;
}
public int GetHashCode(KeyValuePair<String, Object> obj) {
return obj.GetHashCode();
}
}
public class NumberFormatInfo {
public string[] pattern;
public int decimals;
public string groupSeparator;
public string decimalSeparator;
public int[] groupSizes;
public string positive;
public string negative;
public NumberClassFormatInfo percent;
public NumberClassFormatInfo currency;
public class NumberClassFormatInfo {
public string[] pattern;
public int decimals;
public int[] groupSizes;
public string groupSeparator;
public string decimalSeparator;
public string symbol;
}
}
public class DateFormatInfo {
public string name;
public string dateSeparator;
public string timeSeparator;
public int firstDay;
public DayInfo days;
//public string[][] days;
public MonthInfo months;
public MonthInfo monthsGenitive;
//public string[][] months;
//public string[][] monthsGenitive;
public string[] AM;
public string[] PM;
public EraInfo[] eras;
public int twoDigitYearMax;
public Dictionary<String, String> patterns;
internal string convertScriptBlock;
public class EraInfo {
public string name;
public long? start;
public long offset;
}
public class MonthInfo {
public string[] names;
public string[] namesAbbr;
}
public class DayInfo {
public string[] names;
public string[] namesAbbr;
public string[] namesShort;
}
}
}
public class Program {
private static Minifier minifier = new Minifier();
private static CodeSettings codeSettings = new CodeSettings {
CombineDuplicateLiterals = true
};
private static void WriteCulture(string outputdir, CultureInfo culture, StringBuilder aggregateScript) {
var globInfo = GlobalizationInfo.GetGlobInfo(culture);
var diff = culture == CultureInfo.InvariantCulture ? globInfo.ToDictionary() : GlobalizationInfo.DiffGlobInfos(GlobalizationInfo.InvariantGlobInfo, globInfo.ToDictionary());
var script = GlobalizationInfo.GenerateJavaScript(culture, culture.Name, diff, aggregateScript);
var filePath = Path.Combine(outputdir, "jQuery.glob." + (String.IsNullOrEmpty(culture.Name) ? "invariant" : culture.Name) + ".js");
File.WriteAllText(filePath, script);
Console.WriteLine(filePath);
// minimize
var minScript = minifier.MinifyJavaScript(script, codeSettings);
string minPath = Path.ChangeExtension(filePath, "min.js");
File.WriteAllText(minPath, minScript);
Console.WriteLine(minPath);
}
[STAThread]
static void Main(string[] args) {
string outputdir = args.Length > 0 ? args[0] : "output";
Directory.CreateDirectory(outputdir);
GlobalizationInfo.InvariantGlobInfo = GlobalizationInfo.GetGlobInfo(CultureInfo.InvariantCulture).ToDictionary();
StringBuilder aggregateScript = new StringBuilder();
aggregateScript.Append(
@"(function($) {
var culture, cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard;
");
WriteCulture(outputdir, CultureInfo.InvariantCulture, null);
int count = 0;
foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) {
if (!String.IsNullOrEmpty(culture.Name) && culture != CultureInfo.InvariantCulture) {
WriteCulture(outputdir, culture, aggregateScript);
count++;
}
}
aggregateScript.Append(@"
})(jQuery);");
string aggregateScriptString = aggregateScript.ToString();
string aggregatePath = Path.Combine(outputdir, "jQuery.glob.all.js");
File.WriteAllText(aggregatePath, aggregateScriptString);
Console.WriteLine(aggregatePath);
// minimize
var minScript = minifier.MinifyJavaScript(aggregateScriptString, codeSettings);
string minPath = Path.ChangeExtension(aggregatePath, "min.js");
File.WriteAllText(minPath, minScript);
Console.WriteLine(minPath);
// generate the
Console.WriteLine("Done! Generated scripts for a total of {0} cultures, and 1 aggregate script.", count);
}
}
}