--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+ <meta http-equiv="X-UA-Compatible" content="IE=9" />
+ <link rel="stylesheet" type="text/css" href="../../../css/styles.css" />
+ <link rel="stylesheet" type="text/css" href="../../../css/snippet.css" />
+ <script type="text/javascript" src="../../../scripts/snippet.js"></script>
+ <script type="text/javascript" src="../../../scripts/jquery.util.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/common.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/core.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/search.js" charset="utf-8"></script>
+ <title>Globalization</title>
+ </head>
+ <body onload="prettyPrint()" style="overflow: auto;">
+
+ <div id="toc-navigation">
+ <div id="profile">
+ <p><img alt="Mobile Web" src="../../../images/mobile_s_w.png"/> <img alt="Wearable Web" src="../../../images/wearable_s_w.png"/></p>
+ </div>
+
+ <div id="toc_border"><div id="toc">
+ <p class="toc-title">Related Info</p>
+ <ul class="toc">
+ <li><a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm">Globalization Tutorial</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html">Globalization API for Mobile Web</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/cordova/globalization.html">Globalization API for Wearable Web</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/tv/tizen/cordova/globalization.html">Globalization API for TV Web</a></li>
+ </ul>
+ </div></div>
+</div>
+
+<div id="container"><div id="contents"><div class="content">
+ <h1>Globalization</h1>
+
+<p>
+The Globalization API gives the possibility to get information about user's locale, language and timezone. It also enables to convert strings, numbers and dates according the user's locale.
+</p>
+
+<table class="note">
+ <tbody>
+ <tr>
+ <th class="note">Note</th>
+ </tr>
+ <tr>
+ <td class="note">You need to wait for <span style="font-family: monospace">deviceready</span> event before using Globalization Cordova API.
+ <pre class="prettyprint">document.addEventListener( "deviceready", onDeviceReady );
+
+function onDeviceReady() {
+ //Cordova is ready...
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>
+All functions (ie. getPrefferedLanguage, getLocaleName etc.) are accesible by the <a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html#GlobalizationManager">navigator.globalization</a> object.
+</p>
+
+<h2>Obtaining locale information</h2>
+<p>
+With the Globalization API you can obtain the following locale information:
+<ul>
+ <li>User's current language <span style="font-family: monospace">BCP 47</span> identifier (eg. en-US). See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#current_language">example</a>.</li>
+ <li>User's current locale <span style="font-family: monospace">BCP 47</span> identifier (eg. en-US). See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#current_locale">example</a>.</li>
+ <li>Pattern string to format and parse currency and <span style="font-family: monospace">ISO 4217</span> currency code. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#currency">example</a>.</li>
+ <li>Names of months and names of the days of the week. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#names_of_months_and_days">example</a>.</li>
+ <li>Pattern string to format and parse dates. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#date_format">example</a>.</li>
+ <li>First day of the week. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#first_day_of_week">example</a>.</li>
+ <li>Pattern string to format and parse numbers. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#number_format">example</a>.</li>
+ <li>Is Daylight Saving Time in effect for a given date. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#dst">example</a>.</li>
+</ul>
+</p>
+
+<h2>Converting data</h2>
+<p>
+ With the Globalization API you can convert strings, numbers and dates according to the user's locale. The following conversions are available:
+ <ul>
+ <li>date to string - see the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#conversions">example</a>.</li>
+ <li>string to date - see the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#conversions">example</a>.</li>
+ <li>number to string - see the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#conversions">example</a>.</li>
+ <li>string to number - see the <a href="../../../../../org.tizen.tutorials/html/web/tizen/cordova/globalization_tutorial_w.htm#conversions">example</a>.</li>
+ </ul>
+</p>
+
+<script type="text/javascript" src="../../../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../../../scripts/showhide.js"></script>
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../../../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=9" />
+ <link rel="stylesheet" type="text/css" href="../../../css/styles.css" />
+ <link rel="stylesheet" type="text/css" href="../../../css/snippet.css" />
+ <script type="text/javascript" src="../../../scripts/snippet.js"></script>
+ <script type="text/javascript" src="../../../scripts/jquery.util.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/common.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/core.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../../scripts/search.js" charset="utf-8"></script>
+ <title>Globalization</title>
+</head>
+
+<body onload="prettyPrint()" style="overflow: auto;">
+
+<div id="toc-navigation">
+ <div id="profile">
+ <p><img alt="Mobile Web" src="../../../images/mobile_s_w.png"/> <img alt="Wearable Web" src="../../../images/wearable_s_w.png"/></p>
+ </div>
+ <div id="toc_border"><div id="toc">
+ <p class="toc-title">Content</p>
+ <ul class="toc">
+ <li><a href="#current_language">Current language</a></li>
+ <li><a href="#current_locale">Current locale</a></li>
+ <li><a href="#currency">Currency</a></li>
+ <li><a href="#names_of_months_and_days">Names of the months and names of the days of the week</a></li>
+ <li><a href="#date_format">Date format</a></li>
+ <li><a href="#first_day_of_week">First day of the week</a></li>
+ <li><a href="#number_format">Number format</a></li>
+ <li><a href="#dst">Daylight Saving Time</a></li>
+ <li><a href="#conversions">Conversions</a></li>
+ </ul>
+ <p class="toc-title">Related Info</p>
+ <ul class="toc">
+ <li><a href="../../../../../org.tizen.guides/html/web/tizen/cordova/globalization_w.htm">Globalization Guide</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/cordova/globalization.html">Globalization API for Mobile Web</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/cordova/globalization.html">Globalization API for Wearable Web</a></li>
+ <li><a href="../../../../../org.tizen.web.apireference/html/device_api/tv/tizen/cordova/globalization.html">Globalization API for TV Web</a></li>
+ </ul>
+ </div></div>
+</div>
+
+<div id="container"><div id="contents"><div class="content">
+
+<h1>Globalization</h1>
+
+<p>This tutorial demonstrates how to obtain the user's locale information and how to convert data according to this locale.</p>
+
+<h2 id="current_language">Current language</h2>
+<p>
+The following example demonstrates how to get the current <span style="font-family: monospace">BCP 47</span> language identifier.
+</p>
+<pre class="prettyprint"> // When the browser is set to the en-US language,
+ // this should output the text
+ // similar to the results that follow.
+
+ navigator.globalization.getPreferredLanguage(
+ function (language) { console.log('Language: ' + language.value); },
+ function () { console.log('Error getting language.'); }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">Language: en-US</pre>
+
+<h2 id="current_locale">Current locale</h2>
+<p>
+The following example demonstrates how to get current <span style="font-family: monospace">BCP 47</span> locale identifier.
+</p>
+<pre class="prettyprint"> // When the browser is set to the en-US language,
+ // this should output the text
+ // similar to the results that follow.
+
+ navigator.globalization.getLocaleName(
+ function (locale) { console.log('Locale: ' + locale.value); },
+ function () { console.log('Error getting locale.'); }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">Locale: en-US</pre>
+
+<h2 id="currency">Currency</h2>
+<p>
+The following example demontrates how to obtain information about currency. It containsr:
+<ul>
+ <li>The currency pattern to format and parse the currency values. The patterns follow <span style="font-family: monospace">Unicode Technical Standard #35</span>.</li>
+ <li>The <span style="font-family: monospace">ISO 4217</span> currency code.</li>
+ <li>The number of fractional digits.</li>
+ <li>The rounding increment.</li>
+ <li>The decimal symbol.</li>
+ <li>The grouping symbol.</li>
+</ul>
+</p>
+<pre class="prettyprint"> // When the browser is set to the en-US locale and the selected
+ // currency is United States Dollars, this example outputs
+ // text similar to the results that follow.
+
+ navigator.globalization.getCurrencyPattern(
+ 'USD',
+ function (pattern) {
+ console.log('pattern: ' + pattern.pattern);
+ console.log('code: ' + pattern.code);
+ console.log('fraction: ' + pattern.fraction);
+ console.log('rounding: ' + pattern.rounding);
+ console.log('decimal: ' + pattern.decimal);
+ console.log('grouping: ' + pattern.grouping);
+ },
+ function () { console.log('Error getting pattern.'); }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">pattern: $#,##0.##;($#,##0.##)
+code: USD
+fraction: 2
+rounding: 0
+decimal: .
+grouping: ,</pre>
+
+<h2 id="names_of_months_and_days">Names of the months and names of the days of the week</h2>
+<p>
+This example demonstrates how to obtain names of months. The 3rd argument is <span style="font-family: monospace">{ type: 'wide', item: 'months' }</span>. It causes that names of months are obtained. If you want to obtain names of days of the week, you should pass <span style="font-family: monospace">{ type: 'wide', item: 'days' }</span> as a 3rd argument.
+</p>
+<pre class="prettyprint"> // When the browser is set to the en_US locale,
+ // this example logs the names of months, as per locale settings,
+ // with text similar to the results that follow.
+
+ navigator.globalization.getDateNames(
+ function (names) {
+ for (var i = 0; i < names.value.length; i++) {
+ console.log('month: ' + names.value[i]);
+ }
+ },
+ function () { console.log('Error getting names.'); },
+ { type: 'wide', item: 'months' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">month: January
+month: February
+month: March
+month: April
+month: May
+month: June
+month: July
+month: August
+month: September
+month: October
+month: November
+month: December</pre>
+
+<h2 id="date_format">Date format</h2>
+<p>
+The following example demonstrates how to get information about date format. It contains:
+<ul>
+ <li>The date and time pattern that follows <span style="font-family: monospace">Unicode Technical Standard #35</span>.</li>
+ <li>The abbreviated name of the time zone.</li>
+ <li>The current difference in seconds between the client's time zone and coordinated universal time.</li>
+ <li>The current daylight saving time offset in seconds between the client's non-daylight saving time zone and the client's daylight saving time zone.</li>
+</ul>
+</p>
+<pre class="prettyprint"> // This example displays the locale date pattern.
+ // When the browser is set to the en_US locale,
+ // the text displayed is similar to the results that follow.
+
+ function checkDatePattern () {
+ navigator.globalization.getDatePattern(
+ function (date) { console.log('Date pattern: ' + date.pattern); },
+ function () { console.log('Error getting pattern'); },
+ { formatLength: 'short', selector: 'date and time' }
+ );
+ }
+
+ checkDatePattern();</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">Date pattern: M/d/yyyy h:mm a</pre>
+
+<h2 id="first_day_of_week">First day of the week</h2>
+<p>
+This example demonstrates how to obtain information which day is the first day of the week. 1 means Sunday.
+</p>
+<pre class="prettyprint"> // When the browser is set to the en_US locale,
+ // this outputs the text similar to "day: 1".
+
+ navigator.globalization.getFirstDayOfWeek(
+ function (day) { console.log('day: ' + day.value); },
+ function () { console.log('Error getting first day of week.'); }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">day: 1</pre>
+
+<h2 id="number_format">Number format</h2>
+<p>
+This example demonstrates how to obtain information about number format. It contains:
+<ul>
+ <li>The number pattern that follows <span style="font-family: monospace">Unicode Technical Standard #35</span>.</li>
+ <li>The symbol to use when formatting and parsing, such as percent or currency symbol. It depends on the 3rd argument of the function <span style="font-family: monospace">getNumberPattern</span> which can be <span style="font-family: monospace">'decimal'</span>, <span style="font-family: monospace">'percent'</span> or <span style="font-family: monospace">'currency'</span>.</li>
+ <li>The number of fractional digits.</li>
+ <li>The rounding increment</li>
+ <li>The symbol to use for positive numbers</li>
+ <li>The symbol to use for negative numbers</li>
+ <li>The decimal symbol</li>
+ <li>The grouping symbol</li>
+</ul>
+</p>
+<pre class="prettyprint"> // When the browser is set to the en_US locale,
+ // this example outputs the text
+ // similar to the results that follow.
+
+ navigator.globalization.getNumberPattern(
+ function (pattern) {
+ console.log('pattern: ' + pattern.pattern);
+ console.log('symbol: ' + pattern.symbol);
+ console.log('fraction: ' + pattern.fraction);
+ console.log('rounding: ' + pattern.rounding);
+ console.log('positive: ' + pattern.positive);
+ console.log('negative: ' + pattern.negative);
+ console.log('decimal: ' + pattern.decimal);
+ console.log('grouping: ' + pattern.grouping);
+ },
+ function() { console.log('An error occurred.'); },
+ { type: 'decimal' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">pattern: #,##0.###
+symbol: .
+fraction: 0
+rounding: 0
+positive:
+negative: -
+decimal: .
+grouping: ,</pre>
+
+<h2 id="dst">Daylight Saving Time</h2>
+<p>
+This example shows how to obtain information whether or not daylight savings time is in effect for a given date using current time zone.
+</p>
+<pre class="prettyprint"> // During the summer, and if the browser
+ // is set to a DST-enabled timezone,
+ // this should log text similar to "dst: true":
+
+ navigator.globalization.isDayLightSavingsTime(
+ new Date(),
+ function (date) { console.log('dst: ' + date.dst); },
+ function () { console.log('Error getting the DST state.'); }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">dst: true</pre>
+
+<h2 id="conversions">Conversions</h2>
+<p>
+This example demontrates how to make conversion between strings, numbers and dates according to current locale.
+</p>
+<ul>
+ <li><b>Date to String</b> - converts date formatted to a string according to the client's locale and timezone.
+ <pre class="prettyprint"> // When the browser is set to the en-US language,
+ // this should output text similar to the results that follow.
+ // This example uses the default conversion options.
+
+ navigator.globalization.dateToString(
+ new Date(),
+ function (date) { console.log('Date: ' + date.value); },
+ function () { console.log('Error getting dateString.'); },
+ { formatLength: 'short', selector: 'date and time' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">Date: 9/25/2012 4:21PM</pre>
+ </li>
+ <li><b>String to Date</b> - converts a date formatted as a DOMString to a date object according to the client's locale and timezone.
+ <pre class="prettyprint"> // when the browser is set to the en_US locale,
+ // this example outputs text similar to the results that follow.
+ // Note that the month integer is one less than the string,
+ // as the month integer represents an array index.
+
+ navigator.globalization.stringToDate(
+ '9/25/2012',
+ function (date) {
+ console.log('month: ' + date.month +
+ ', day: ' + date.day +
+ ', year: ' + date.year)
+ },
+ function () { console.log('Error getting date.'); },
+ { selector: 'date' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">month: 8, day: 25, year: 2012</pre>
+ </li>
+ <li><b>Number to String</b> - returns a number formatted as a string according to the client's user preferences.
+ <pre class="prettyprint"> // When the browser is set to the en_US locale,
+ // this code displays the results that follow.
+
+ navigator.globalization.numberToString(
+ 3.1415926,
+ function (number) { console.log('decimal number: ' + number.value); },
+ function () { console.log('Error getting number.'); },
+ { type: 'decimal' }
+ );
+
+ navigator.globalization.numberToString(
+ 1000003,
+ function (number) { console.log('big decimal number: ' + number.value); },
+ function () { console.log('Error getting number.'); },
+ { type: 'decimal' }
+ );
+
+ navigator.globalization.numberToString(
+ 0.3183099,
+ function (number) { console.log('percentile: ' + number.value); },
+ function () { console.log('Error getting number.'); },
+ { type: 'percent' }
+ );
+
+ navigator.globalization.numberToString(
+ 1099.95,
+ function (number) { console.log('currency: ' + number.value); },
+ function () { console.log('Error getting number'); },
+ { type: 'currency' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">decimal number: 3.142
+big decimal number: 1,000,003
+percentile: 32%
+currency: $1,099.95</pre>
+ </li>
+ <li><b>String to Number</b> - parses a number formatted as a string according to the client's user preferences and returns the corresponding number.
+ <pre class="prettyprint"> // When the browser is set to the en_US locale,
+ // this should display the text similar to the results that follow.
+
+ navigator.globalization.stringToNumber(
+ '1234.56',
+ function (number) { console.log('number: ' + number.value); },
+ function () { console.log('Error getting number.'); },
+ { type: 'decimal' }
+ );</pre>
+<p>
+The output:
+</p>
+<pre class="prettyprint">number: 1234.56</pre>
+ </li>
+</ul>
+
+<script type="text/javascript" src="../../../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../../../scripts/showhide.js"></script>
+
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../../../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+</html>