Skip to content

Commit

Permalink
Removed invariant culture. 'en' is the default now.
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinitiesLoop committed Jun 8, 2010
1 parent 214791b commit 099e13a
Show file tree
Hide file tree
Showing 715 changed files with 2,851 additions and 4,062 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jQuery.preferCulture(["es-MX", "fr-FR"]);
alert(jQuery.culture.name) // 'fr'
</pre>

In any case, if no match is found, the invariant culture is selected.
In any case, if no match is found, the 'en' culture is selected.
</p>

<a name="find"></a>
Expand Down Expand Up @@ -152,8 +152,8 @@ alert(obj.foo); // "foo"
Note that localize() will find the closest match available per the same semantics as the jQuery.findClosestCulture function. If there is no match, the translation given is for the neutral culture, if any.
<pre>
jQuery.localize("myplugin", "", {
foo: "foo (invariant)",
bar: "bar (invariant)"
foo: "foo (en)",
bar: "bar (en)"
});
jQuery.localize("myplugin", "fr", {
foo: "foo",
Expand All @@ -168,7 +168,7 @@ alert(jQuery.localize("myplugin").foo); // foo

jQuery.culture = jQuery.cultures["es-MX"];
jQuery.culture = jQuery.cultures["fr-FR"];
alert(jQuery.localize("myplugin").foo); // foo (invariant)
alert(jQuery.localize("myplugin").foo); // foo (en)
</pre>
Also note that localize() does not require loading the culture information script. You may use localize() for localization purposes without utilizing the parsing and formatting functions which depend on the cultures. If you do use both, it does not matter what order you include them in, either may be first -- the jQuery.glob.&lt;code&gt;.js script, or your own script which uses localize().
</p>
Expand Down Expand Up @@ -199,13 +199,13 @@ Each culture is defined in its own script with the naming scheme jQuery.glob.&lt
<p>
The neutral culture that comes with jQuery.glob.js is heavily commented, describing the purpose of each of the fields defined by a culture. Note that every culture includes all of these fields, even if they are the same as the netural culture. However, the script uses jQuery's $.extend to copy from the neutral culture, so looking at the raw scripts will only show you what is different in that culture from the neutral culture. The neutral culture is listed here along with the comments:
<pre>
jQuery.cultures.invariant = {
jQuery.cultures.en = {
// A unique name for the culture in the form &lt;language code&gt;-&lt;country/region code&lt;
name: "invariant",
name: "English",
// the name of the culture in the english language
englishName: "Invariant",
englishName: "English",
// the name of the culture in its own language
nativeName: "Invariant",
nativeName: "English",
// whether the culture uses right-to-left text
isRTL: false,
// 'language' is used for so-called "specific" cultures.
Expand All @@ -225,7 +225,7 @@ jQuery.cultures.invariant = {
// This field should be used to navigate from a specific culture to it's
// more general, neutral culture. If a culture is already as general as it
// can get, the language may refer to itself.
language: "",
language: "en",
// numberFormat defines general number formatting rules, like the digits in
// each grouping, the group separator, and how negative numbers are displayed.
numberFormat: {
Expand Down Expand Up @@ -276,7 +276,7 @@ jQuery.cultures.invariant = {
// string that separates a number from the fractional portion, as in 1.99
'.': ".",
// symbol used to represent currency
symbol: "¤"
symbol: "$"
}
},
// calendars defines all the possible calendars used by this culture.
Expand Down Expand Up @@ -332,17 +332,17 @@ jQuery.cultures.invariant = {
// to see given the portions of the date that are shown.
patterns: {
// short date pattern
d: "MM/dd/yyyy",
d: "M/d/yyyy",
// long date pattern
D: "dddd, dd MMMM yyyy",
D: "dddd, MMMM dd, yyyy",
// short time pattern
t: "HH:mm",
t: "h:mm tt",
// long time pattern
T: "HH:mm:ss",
T: "h:mm:ss tt",
// long date, short time pattern
f: "dddd, dd MMMM yyyy HH:mm",
f: "dddd, MMMM dd, yyyy h:mm tt",
// long date, long time pattern
F: "dddd, dd MMMM yyyy HH:mm:ss",
F: "dddd, MMMM dd, yyyy h:mm:ss tt",
// month/day pattern
M: "MMMM dd",
// month/year pattern
Expand Down
2 changes: 1 addition & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jQuery(function($) {
$.each(sortByName($.cultures), function(i, culture) {
$("<option/>", {
value: culture.name,
text: culture.name + ": " + (culture.englishName || "Invariant") + " (" + (culture.nativeName || "Invariant") + ")"
text: culture.name + ": " + culture.englishName + " (" + culture.nativeName + ")"
}).appendTo("#cultures");
});

Expand Down
2 changes: 1 addition & 1 deletion demo/jquery.ui.datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ window['DP_jQuery_' + dpuuid] = $;

// regional data
var regions = {
"invariant": {
"en": {
"closeText": "Done",
"prevText": "Prev",
"nextText": "Next",
Expand Down
37 changes: 17 additions & 20 deletions generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GlobalizationInfo {
public NumberFormatInfo numberFormat;
public Dictionary<String, DateFormatInfo> calendars;
private CultureInfo culture;
public static Dictionary<String, Object> InvariantGlobInfo;
public static Dictionary<String, Object> BasisGlobInfo;


private static string[] _numberNegativePatterns = "(n)|-n|- n|n-|n -".Split('|');
Expand Down Expand Up @@ -63,15 +63,14 @@ public static Dictionary<String, DateFormatInfo> GetCalendars(CultureInfo cultur
if (type == gregorianType) {
var calendarType = ((GregorianCalendar)calendar).CalendarType;
if (calendarType == GregorianCalendarTypes.USEnglish) {
// we include the Gregorian_USEnglish culture as part of the Invariant culture
// we include the Gregorian_USEnglish culture as part of the built-in 'en' 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.
// to Gregorian_USEnglish.
name = " Gregorian_USEnglish";
}
else {
Expand Down Expand Up @@ -300,13 +299,13 @@ public Dictionary<String, Object> ToDictionary() {
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"];
Dictionary<String, Object> basisStandardCal = null;
if (GlobalizationInfo.BasisGlobInfo != null) {
basisStandardCal = (Dictionary<String, Object>)((Dictionary<String, Object>)GlobalizationInfo.BasisGlobInfo["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);
// make each calendar a diff from the standard basis calendar
cals[pair.Key] = cal = DiffGlobInfos(basisStandardCal, cal);
// apply convert script if it exists
if (!String.IsNullOrEmpty(pair.Value.convertScriptBlock)) {
cal["convert"] = pair.Value.convertScriptBlock;
Expand All @@ -328,7 +327,7 @@ public static string GenerateJavaScript(CultureInfo culture, string name, Dictio
string cultureFragment = ToJavaScript(culture, dictionary, 2, false);

if (aggregateScript != null) {
aggregateScript.AppendFormat(CultureInfo.InvariantCulture, @" culture = cultures[""{0}""] = $.extend(true, {{}}, invariant, {{
aggregateScript.AppendFormat(CultureInfo.InvariantCulture, @" culture = cultures[""{0}""] = $.extend(true, {{}}, en, {{
{1}
}}, cultures[""{0}""]);
culture.calendar = culture.calendars.standard;
Expand All @@ -337,9 +336,9 @@ public static string GenerateJavaScript(CultureInfo culture, string name, Dictio

return string.Format(CultureInfo.InvariantCulture, @"(function($) {{
var cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard,
culture = cultures[""{0}""] = $.extend(true, {{}}, invariant, {{
en = cultures.en,
standard = en.calendars.standard,
culture = cultures[""{0}""] = $.extend(true, {{}}, en, {{
{1}
}}, cultures[""{0}""]);
culture.calendar = culture.calendars.standard;
Expand Down Expand Up @@ -535,7 +534,7 @@ public class Program {

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 diff = (culture == CultureInfo.InvariantCulture || culture.Name.Equals("en")) ? globInfo.ToDictionary() : GlobalizationInfo.DiffGlobInfos(GlobalizationInfo.BasisGlobInfo, 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");

Expand All @@ -552,22 +551,20 @@ private static void WriteCulture(string outputdir, CultureInfo culture, StringBu
static void Main(string[] args) {
string outputdir = args.Length > 0 ? args[0] : "output";
Directory.CreateDirectory(outputdir);
GlobalizationInfo.InvariantGlobInfo = GlobalizationInfo.GetGlobInfo(CultureInfo.InvariantCulture).ToDictionary();
GlobalizationInfo.BasisGlobInfo = GlobalizationInfo.GetGlobInfo(CultureInfo.CreateSpecificCulture("en")).ToDictionary();

StringBuilder aggregateScript = new StringBuilder();
aggregateScript.Append(
@"(function($) {
var culture, cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard;
en = cultures.en,
standard = en.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) {
if (!String.IsNullOrEmpty(culture.Name) && culture != CultureInfo.InvariantCulture && culture.Name != "en") {
WriteCulture(outputdir, culture, aggregateScript);
count++;
}
Expand Down
12 changes: 12 additions & 0 deletions generator/generator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
..\jquery.glob.js = ..\jquery.glob.js
..\demo\jquery.ui.datepicker.js = ..\demo\jquery.ui.datepicker.js
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{2D93F775-493B-4A44-8B9F-84F6195EC4FC}"
ProjectSection(SolutionItems) = preProject
..\demo\demo-datepicker.html = ..\demo\demo-datepicker.html
..\demo\demo.html = ..\demo\demo.html
..\demo\demo.js = ..\demo\demo.js
..\demo\jquery.ui.datepicker.js = ..\demo\jquery.ui.datepicker.js
EndProjectSection
EndProject
Global
Expand All @@ -23,4 +32,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2D93F775-493B-4A44-8B9F-84F6195EC4FC} = {4C0E66A7-F722-4410-8612-AF97F54F25E3}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion generator/glob-generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="AjaxMin">
<HintPath>C:\Program Files\Microsoft\Microsoft Ajax Minifier 4\AjaxMin.dll</HintPath>
<HintPath>C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier 4\AjaxMin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
7 changes: 3 additions & 4 deletions globinfo/jQuery.glob.af-ZA.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function($) {
var cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard,
culture = cultures["af-ZA"] = $.extend(true, {}, invariant, {
en = cultures.en,
standard = en.calendars.standard,
culture = cultures["af-ZA"] = $.extend(true, {}, en, {
name: "af-ZA",
englishName: "Afrikaans (South Africa)",
nativeName: "Afrikaans (Suid Afrika)",
Expand All @@ -18,7 +18,6 @@
},
calendars: {
standard: $.extend(true, {}, standard, {
name: "Gregorian_Localized",
days: {
names: ["Sondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrydag","Saterdag"],
namesAbbr: ["Son","Maan","Dins","Woen","Dond","Vry","Sat"],
Expand Down
2 changes: 1 addition & 1 deletion globinfo/jQuery.glob.af-ZA.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions globinfo/jQuery.glob.af.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function($) {
var cultures = $.cultures,
invariant = cultures.invariant,
standard = invariant.calendars.standard,
culture = cultures["af"] = $.extend(true, {}, invariant, {
en = cultures.en,
standard = en.calendars.standard,
culture = cultures["af"] = $.extend(true, {}, en, {
name: "af",
englishName: "Afrikaans",
nativeName: "Afrikaans",
Expand All @@ -18,7 +18,6 @@
},
calendars: {
standard: $.extend(true, {}, standard, {
name: "Gregorian_Localized",
days: {
names: ["Sondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrydag","Saterdag"],
namesAbbr: ["Son","Maan","Dins","Woen","Dond","Vry","Sat"],
Expand Down
2 changes: 1 addition & 1 deletion globinfo/jQuery.glob.af.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 099e13a

Please sign in to comment.