Skip to content

Commit 814341d

Browse files
author
InfinitiesLoop
committed
Fix TOC in readme on github
1 parent eb5d9ca commit 814341d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This jQuery plugin enables complex culture-aware number and date parsing and for
2020
<li><a href="#dates">Date Formatting</a></li>
2121
</ul>
2222

23+
<!-- using named anchors to workaround github stripping IDs from readme -->
2324
<a name="why"></a>
2425
<h2 id="why">Why Globalization?</h2>
2526
<p>
@@ -29,6 +30,7 @@ Each language, and the countries that speak that language, have different expect
2930
A user using an application should be able to read and write dates and numbers in the format they are occustomed to. This plugin makes this possible, providing an API to convert user-entered numbers and dates -- in their own format -- into real numbers and dates, and conversely, to format numbers and dates into that format.
3031
</p>
3132

33+
<a name="what"></a>
3234
<h2 id="what">What is a Culture?</h2>
3335
<p>
3436
jQuery.glob.js defines roughly 350 cultures. Part of the reason for this large number, besides there being a lot of cultures of the world, is because for some languages, expectations differ amoung the countries that speak it. English, for example, is an official language in dozens of countries. Despite the language being English, the expected date formatting still greatly differs between them.
@@ -40,11 +42,13 @@ So, it seems it is not useful to define cultures by their language alone. Nor is
4042
Yet, it is perhaps unreasonable to expect application developers to cater to every possible language/country combination perfectly. It is important then to define so-called "neutral" cultures based on each language. This culture defines the most likely accepted set of rules by anyone speaking that language, whatever the country. Neutral cultures are defined only by their language code. For example, "es" is the neutral culture for Spanish.
4143
</p>
4244

45+
<a name="cultures"></a>
4346
<h2 id="cultures">jQuery.cultures</h2>
4447
<p>
4548
A mapping of culture code to that culture. For example, jQuery.cultures.fr is an object representing the complete culture definition for the neutral French culture. Note that jQuery.glob.js alone only includes an English culture. To get additional cultures, you must seperately reference one or more of the culture scripts that come with it. See below on what fields are defined in each culture.
4649
</p>
4750

51+
<a name="culture"></a>
4852
<h2 id="culture">jQuery.culture</h2>
4953
<p>
5054
This is set to the culture currently being used. This serves as the default culture if no culture is specified on the various parsing and formatting functions. For example, to change the current culture, set it to one of the available cultures:
@@ -53,6 +57,7 @@ jQuery.culture = jQuery.cultures["FR-fr"];
5357
</pre>
5458
</p>
5559

60+
<a name="prefer"></a>
5661
<h2 id="prefer">jQuery.preferCulture</h2>
5762
<p>
5863
An application that supports globalization and/or localization will need to have a way to determine the user's preference. Attempting to automatically determine the appropriate culture is useful, but it is good practice to always offer the user a choice, by whatever means.
@@ -77,11 +82,13 @@ alert(jQuery.culture.name) // 'fr'
7782
In any case, if no match is found, the invariant culture is selected.
7883
</p>
7984

85+
<a name="find"></a>
8086
<h2 id="find">jQuery.findClosestCulture</h2>
8187
<p>
8288
Just like preferCulture, but it returns the matching culture, if any, rather than setting jQuery.culture to it.
8389
</p>
8490

91+
<a name="format"></a>
8592
<h2 id="format">jQuery.format(value, format, culture)</h2>
8693
<p>
8794
Formats a date or number according to the given format string and the given culture (or the current culture if not specified). See the section below on number and date formatting tokens for details on the available formats.
@@ -97,6 +104,7 @@ jQuery.format(new Date(1955,10,5), "dddd MMMM d, yyyy"); // Saturday November 5,
97104
</pre>
98105
</p>
99106

107+
<a name="parseInt"></a>
100108
<h2 id="parseInt">jQuery.parseInt(value, radix, culture)</h2>
101109
<p>
102110
Parses a string representing a whole number in the given the radix (10 by default), taking into account any formatting rules followed by the given culture (or the current culture, if not specified).
@@ -108,6 +116,7 @@ jQuery.parseInt("1.234,56"); // 1234
108116
</pre>
109117
</p>
110118

119+
<a name="parseFloat"></a>
111120
<h2 id="parseFloat">jQuery.parseFloat(value, radix, culture)</h2>
112121
<p>
113122
Parses a string representing a floating point number in the given the radix (10 by default), taking into account any formatting rules followed by the given culture (or the current culture, if not specified).
@@ -124,6 +133,7 @@ jQuery.parseDate("1/2/2003"); // Sat Feb 01 2003
124133
</pre>
125134
</p>
126135

136+
<a name="localize"></a>
127137
<h2 id="localize">jQuery.localize(key, culture, value)</h2>
128138
<p>
129139
Gets or sets a localized value. This function allows you to extend the information available to a particular culture, and to easily retrieve it without worrying about finding the most appropriate culture. For example, to define the word "translate" in French:
@@ -164,6 +174,7 @@ alert(jQuery.localize("myplugin").foo); // foo (invariant)
164174
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().
165175
</p>
166176

177+
<a name="extend"></a>
167178
<h2 id="extend">Utilizing and Extending Cultures</h2>
168179
<p>
169180
The culture information included with each culture is mostly necessary for the parsing and formatting methods, but not all of it. For example, the the Native and English names for each culture is given, as well as a boolean indicating whether the language is right-to-left. This may be useful information for your own purposes. You may also add to the culture information directly if so desired. It is important to do so in a way that handles the fact that the culture info may not be provided, may not be provided yet, or may already be provided. Using jQuery's extend() method, it is possible to define a culture in a way that both defines if it does not exist and adds to it if it does exist.
@@ -181,6 +192,7 @@ jQuery.cultures.fr = jQuery.extend(true, {
181192
Using this mechanism, the 'fr' culture will be created if it does not exist. And if it does, the given values will be added to it, taking care not to overwrite anything that is already defined (if you'd prefer to overwrite, you'd switch the last two arguments). When the jQuery.glob.fr.js script is eventually included, it too uses this technique, ensuring addition to the already-defined culture information.
182193
</p>
183194

195+
<a name="defining"></a>
184196
<h2 id="defining">Defining Culture Information</h2>
185197
<p>
186198
Each culture is defined in its own script with the naming scheme jQuery.glob.&lt;code&gt;.js (along with its minified version, jQuery.glob.&lt;code&gt;.min.js). You may include any number of these scripts, making them available in the jQuery.cultures mapping. Including one of these scripts does NOT automatically make it the default culture selected with jQuery.culture.
@@ -372,6 +384,7 @@ $.culture.calendar = $.culture.calendars.standard;
372384

373385
</p>
374386

387+
<a name="numbers"></a>
375388
<h2 id="numbers">Number Formatting</h2>
376389
<p>
377390
When formatting a number with format(), the main purpose is to convert the number into a human readable string using the culture's standard grouping and decimal rules. The rules between cultures can vary a lot. For example, in some cultures, the grouping of numbers is done unevenly. In the "te-IN" culture (Telugu in India), groups have 3 digits and then 2 digits. The number 1000000 (one million) is written as "10,00,000". Some cultures do not group numbers at all.
@@ -406,6 +419,7 @@ jQuery.format(0.12345, "p4"); // 12.3450 %
406419
Parsing with parseInt and parseFloat also accepts any of these formats.
407420
</p>
408421

422+
<a name="dates"></a>
409423
<h2 id="dates">Date Formatting</h2>
410424
<p>
411425
Date formatting varies wildly by culture, not just in the spelling of month and day names, and the date separator, but by the expected order of the various date components, whether to use a 12 or 24 hour clock, and how months and days are abbreivated. Many cultures even include "genative" month names, which are different from the typical names and are used only in certain cases.

0 commit comments

Comments
 (0)