diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dijit/tests/i18n | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2 |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dijit/tests/i18n')
-rw-r--r-- | includes/js/dijit/tests/i18n/README | 4 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/currency.html | 210 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/date.html | 155 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/digit.html | 294 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/module.js | 18 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/number.html | 136 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/test_i18n.js | 206 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/textbox.html | 173 | ||||
-rw-r--r-- | includes/js/dijit/tests/i18n/time.html | 207 |
9 files changed, 1403 insertions, 0 deletions
diff --git a/includes/js/dijit/tests/i18n/README b/includes/js/dijit/tests/i18n/README new file mode 100644 index 0000000..a6516b6 --- /dev/null +++ b/includes/js/dijit/tests/i18n/README @@ -0,0 +1,4 @@ +Global Verification Tests (GVT) + +In order to run these tests, you will need full locale support in Dojo. Dojo only ships with a small subset by default. +See util/buildscripts/cldr for an ant-based build script. diff --git a/includes/js/dijit/tests/i18n/currency.html b/includes/js/dijit/tests/i18n/currency.html new file mode 100644 index 0000000..62108b2 --- /dev/null +++ b/includes/js/dijit/tests/i18n/currency.html @@ -0,0 +1,210 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test CurrencyTextBox</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp']"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.NumberTextBox"); + dojo.require("dijit.form.CurrencyTextBox"); + dojo.require("dijit.form.DateTextBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test for Currency</h1> + +<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button> --> + <p> + Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", and "ja-jp" + and currencies CNY, EGP, EUR, JPY. If not, convert these CLDR data and put them there. + </p> + + <script> + (function() { + genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [ + + { attrs: {Currency: "CNY", lang: "zh-cn"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", + value: "123456789.46", + expValue: "¥123,456,789.46", + comment: "" + }, + { attrs: {Currency: "CNY", lang: "zh-cn"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", + value: "-123456789.46", + expValue: "-¥123,456,789.46", + comment: "" + }, + + { attrs: {Currency: "EUR", lang: "fr-fr"}, + desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>", + value: "123456789.46", + expValue: "123 456 789,46 €", + comment: "" + }, + { attrs: {Currency: "EUR", lang: "fr-fr"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>", + value: "-123456789.46", + expValue: "-123 456 789,46 €", + comment: "" + }, + + { attrs: {Currency: "JPY", lang: "ja-jp"}, + desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", + value: "123456789.46", + expValue: "¥123,456,789", + comment: "" + }, + { attrs: {Currency: "JPY", lang: "ja-jp"}, + desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", + value: "-123456789.46", + expValue: "-¥123,456,789", + comment: "" + } + ]); + + genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [ + + { attrs: {Currency: "CNY", lang: "zh-cn"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", + value: 123456789.46, + expValue: "¥123,456,789.46", + comment: "" + }, + { attrs: {Currency: "CNY", lang: "zh-cn"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", + value: -123456789.46, + expValue: "-¥123,456,789.46", + comment: "" + }, + + { attrs: {Currency: "EUR", lang: "fr-fr"}, + desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>", + value: 123456789.46, + expValue: "123 456 789,46 €", + comment: "" + }, + { attrs: {Currency: "EUR", lang: "fr-fr"}, + desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>", + value: -123456789.46, + expValue: "-123 456 789,46 €", + comment: "" + }, + + { attrs: {Currency: "JPY", lang: "ja-jp"}, + desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", + value: 123456789, + expValue: "¥123,456,789", + comment: "" + }, + { attrs: {Currency: "JPY", lang: "ja-jp"}, + desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", + value: -123456789, + expValue: "-¥123,456,789", + comment: "" + } + ]); + + dojo.parser.parse(); + + })(); + + </script> + + <h2 class="testTitle">Issues & Comments</h2> + <h3 class="testTitle"><a name="cmt_1">Issue #1<sup style="color:blue">Fixed</sup></a></h3> + <p> + Some browsers like FireFox have a bug on the non-breaking space character (U+00A0, <b>&nbsp;</b> or <b>&#160;</b> or + <b>&#xA0;</b> in HTML). + They always convert the NBSP character to a normal space (U+0020, <b>&#x20;</b> in HTML) automatically in the following circumstances: + </p> + <ul> + <li>Copy text from the page</li> + <li>Use <b>innerHTML</b> to get the content of a certain element</li> + <li>Use <b>value</b> to get an <b>INPUT</b> element's value</li> + </ul> + + <p> + You cannot read a real NBSP character from an <b>INPUT</b> element on these browsers. It causes issues when some formatting data in CLDR + contains an NBSP character. For example, + </p> + <ul> + <li>Many locales like French use an NBSP character as a group separator in numbers</li> + <li>French and Finnish use NBSP characters in their percentage and currency format patterns respectively</li> + </ul> + + <p> + So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser. + </p> + + <h3 class="testTitle"><a name="cmt_2">Issue #2<sup style="color:blue">Fixed: the CLDR data generator should be fixed by adding code to convert U+200F to "\u200F" in nls JS files.</sup></a></h3> + <p> + Most Bidi currency symbols contain an LTR-MARK (U+200F) character at the very beginning. + But Firefox ignores it when it is not in any escaping form. This should be a bug of Firefox. + For example, click <a href="javascript:alert(''.indexOf('\u200F'))"><code>alert(''.indexOf('\u+200F'))</code></a> (there is a U+200F in the empty-looking string): + </p> + <ul> + <li>In Firefox, shows "-1" -- no U+200F found</li> + <li>In IE & Opera, shows "0" -- the U+200F is found</li> + </ul> + <p> + But if the U+200F is in some escaping form, Firefox will work as well as other browsers. + Click <a href="javascript:alert('\u200F'.indexOf('\u200F'))"><code>alert('\u200F'.indexOf('\u+200F'))</code></a> to see the same result both in Firefox and IE: + </p> + + + <h3 class="testTitle"><a name="cmt_3">Issue #3<sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3> + <p> + Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi. + For example, ICU formats a number data into Indic number characters by default in the Arabic locale. + However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser). + </p> + + </body> +</html> diff --git a/includes/js/dijit/tests/i18n/date.html b/includes/js/dijit/tests/i18n/date.html new file mode 100644 index 0000000..b4aa4cd --- /dev/null +++ b/includes/js/dijit/tests/i18n/date.html @@ -0,0 +1,155 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test DateTextBox</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp','ru-ru','en-us','de-de','es-es','it-it','pt-br','ko-kr','zh-tw']"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.NumberTextBox"); + dojo.require("dijit.form.CurrencyTextBox"); + dojo.require("dijit.form.DateTextBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + <script> + function gen4DateFormat(testCases, language, locale, date, short, shortCmt, medium, mediumCmt, long, longCmt, full, fullCmt) { + testCases.push({ + attrs: {constraints: "{formatLength:'short'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Short</b>", + value: date, + expValue: short, + comment: shortCmt + }); + testCases.push({ + attrs: {constraints: "{formatLength:'medium'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Medium</b>", + value: date, + expValue: medium, + comment: mediumCmt + }); + testCases.push({ + attrs: {constraints: "{formatLength:'long'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Long</b>", + value: date, + expValue: long, + comment: longCmt + }); + testCases.push({ + attrs: {constraints: "{formatLength:'full'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Full</b>", + value: date, + expValue: full, + comment: fullCmt + }); + } + </script> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test for Date</h1> + +<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button>--> + <p> + Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", "ja-jp", "ru-ru", "hi-in", "en-us" and "ar-eg". If not, convert these CLDR data and put them there. + </p> + + <script> + (function() { + var testCases = []; + gen4DateFormat(testCases, "ru-ru", "ru_RU", "2005-07-31", + "31.07.05", "", "31.07.2005", "", "31 июля 2005 г.", "Failed in Firefox. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>", "31 июля 2005 г.", "Failed in Firefox. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"); + gen4DateFormat(testCases, "zh-cn", "zh_CN", "2005-07-31", + "05-7-31", "", "2005-7-31", "", "2005年7月31日", "", "2005年7月31日星期日", ""); + gen4DateFormat(testCases, "en-us", "en_US", "2005-07-31", + "7/31/05", "", "Jul 31, 2005", "", "July 31, 2005", "", "Sunday, July 31, 2005", ""); + gen4DateFormat(testCases, "fr-fr", "fr_FR", "2005-07-31", + "31/07/05", "", "31 juil. 2005", "", "31 juillet 2005", "", "dimanche 31 juillet 2005", ""); + gen4DateFormat(testCases, "ja-jp", "ja_JP", "2005-07-31", + "05/07/31", "", "2005/07/31", "", "2005年7月31日", "", "2005年7月31日日曜日", ""); + gen4DateFormat(testCases, "de-de", "de_DE", "2005-07-31", + "31.07.05", "", "31.07.2005", "", "31. Juli 2005", "", "Sonntag, 31. Juli 2005", ""); + gen4DateFormat(testCases, "es-es", "es_ES", "2005-07-31", + "31/07/05", "", "31/07/2005", "", "31 de julio de 2005", "", "domingo 31 de julio de 2005", ""); + gen4DateFormat(testCases, "pt-br", "pt-BR", "2005-07-31", + "31/07/05", "", "31/07/2005", "", "31 de julho de 2005", "", "domingo, 31 de julho de 2005", ""); + gen4DateFormat(testCases, "it-it", "it-IT", "2005-07-31", + "31/07/05", "", "31/lug/2005", "", "31 luglio 2005", "", "domenica 31 luglio 2005", ""); + gen4DateFormat(testCases, "ko-kr", "ko-KR", "2005-07-31", + "05. 7. 31.", "", "2005. 7. 31.", "", "2005년 7월 31일", "", "2005년 7월 31일 일요일", ""); + gen4DateFormat(testCases, "zh-tw", "zh-TW", "2005-07-31", + "2005/7/31", "", "2005/7/31", "", "2005年7月31日", "", "2005年7月31日星期日", ""); + genFormatTestCases("Date Format", "dijit.form.DateTextBox", testCases); + + testCases = []; + gen4DateFormat(testCases, "ru-ru", "ru_RU", new Date(2005, 6, 31), + "31.07.05", "", "31.07.2005", "", "31 июля 2005 г.", "Failed in Firefox. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>", "31 июля 2005 г.", "Failed in Firefox. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"); + gen4DateFormat(testCases, "zh-cn", "zh_CN", new Date(2005, 6, 31), + "05-7-31", "", "2005-7-31", "", "2005年7月31日", "", "2005年7月31日星期日", ""); + gen4DateFormat(testCases, "en-us", "en_US", new Date(2005, 6, 31), + "7/31/05", "", "Jul 31, 2005", "", "July 31, 2005", "", "Sunday, July 31, 2005", ""); + gen4DateFormat(testCases, "fr-fr", "fr_FR", new Date(2005, 6, 31), + "31/07/05", "", "31 juil. 2005", "", "31 juillet 2005", "", "dimanche 31 juillet 2005", ""); + gen4DateFormat(testCases, "ja-jp", "ja_JP", new Date(2005, 6, 31), + "05/07/31", "", "2005/07/31", "", "2005年7月31日", "", "2005年7月31日日曜日", ""); + gen4DateFormat(testCases, "de-de", "de_DE", new Date(2005, 6, 31), + "31.07.05", "", "31.07.2005", "", "31. Juli 2005", "", "Sonntag, 31. Juli 2005", ""); + gen4DateFormat(testCases, "es-es", "es_ES", new Date(2005, 6, 31), + "31/07/05", "", "31/07/2005", "", "31 de julio de 2005", "", "domingo 31 de julio de 2005", ""); + gen4DateFormat(testCases, "pt-br", "pt-BR", new Date(2005, 6, 31), + "31/07/05", "", "31/07/2005", "", "31 de julho de 2005", "", "domingo, 31 de julho de 2005", ""); + gen4DateFormat(testCases, "it-it", "it-IT", new Date(2005, 6, 31), + "31/07/05", "", "31/lug/2005", "", "31 luglio 2005", "", "domenica 31 luglio 2005", ""); + gen4DateFormat(testCases, "ko-kr", "ko-KR", new Date(2005, 6, 31), + "05. 7. 31.", "", "2005. 7. 31.", "", "2005년 7월 31일", "", "2005년 7월 31일 일요일", ""); + gen4DateFormat(testCases, "zh-tw", "zh-TW", new Date(2005, 6, 31), + "2005/7/31", "", "2005/7/31", "", "2005年7月31日", "", "2005年7月31日星期日", ""); + genValidateTestCases("Date Validate", "dijit.form.DateTextBox", testCases); + + dojo.parser.parse(); + })(); + </script> + </body> +</html> diff --git a/includes/js/dijit/tests/i18n/digit.html b/includes/js/dijit/tests/i18n/digit.html new file mode 100644 index 0000000..dc3ed7a --- /dev/null +++ b/includes/js/dijit/tests/i18n/digit.html @@ -0,0 +1,294 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test Hindi/Arabic numerals</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, extraLocale: ['ar-eg','hi-in']"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.NumberTextBox"); + dojo.require("dijit.form.CurrencyTextBox"); + dojo.require("dijit.form.DateTextBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <script> + function gen4DateFormat(testCases, language, locale, date, short, shortCmt, medium, mediumCmt, long, longCmt, full, fullCmt) { + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'short', localeDigit: true}" : "{formatLength:'short'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Short</b>", + value: date, + expValue: short, + comment: shortCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'medium', localeDigit: true}" : "{formatLength:'medium'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Medium</b>", + value: date, + expValue: medium, + comment: mediumCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'long', localeDigit: true}" : "{formatLength:'long'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Long</b>", + value: date, + expValue: long, + comment: longCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'full', localeDigit: true}" : "{formatLength:'full'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Full</b>", + value: date, + expValue: full, + comment: fullCmt + }); + } + </script> + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test for Number</h1> + +<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button>--> + <p> + Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "ar-eg" and "hi-in". If not, convert these CLDR data and put them there. + </p> + + <script> + (function() { + + genFormatTestCases("Number Format", "dijit.form.NumberTextBox", [ + { attrs: {lang: "ar-eg"}, + desc: "Locale: ar_EG", + value: "12345.067", + expValue: "12٬345٫067", + comment: "" + }, + { attrs: {lang: "ar-eg"}, + desc: "Locale: ar_EG", + value: "-12345.067", + expValue: "12٬345٫067-", + comment: "" + }, + + { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: ar_EG", + value: "12345.067", + expValue: "١٢\u066C٣٤٥\u066B٠٦٧", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: ar_EG", + value: "-12345.067", + expValue: "١٢\u066C٣٤٥\u066B٠٦٧-", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + + { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"}, + desc: "Locale: hi_IN", + value: "123456789.068", + expValue: "१२,३४,५६,७८९.०६८", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"}, + desc: "Locale: hi_IN", + value: "-123456789.068", + expValue: "-१२,३४,५६,७८९.०६८", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + } + ]); + + genValidateTestCases("Number Validate", "dijit.form.NumberTextBox", [ + + { attrs: {lang: "ar-eg"}, + desc: "Locale: ar_EG", + value: 12345.067, + expValue: "12٬345٫067", + comment: "" + }, + { attrs: {lang: "ar-eg"}, + desc: "Locale: ar_EG", + value: -12345.067, + expValue: "12٬345٫067-", + comment: "" + }, + + { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: ar_EG", + value: 12345.067, + expValue: "١٢\u066C٣٤٥\u066B٠٦٧", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: ar_EG", + value: -12345.067, + expValue: "١٢\u066C٣٤٥\u066B٠٦٧-", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + + { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"}, + desc: "Locale: hi_IN", + value: 123456789.068, + expValue: "१२,३४,५६,७८९.०६८", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + }, + { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"}, + desc: "Locale: hi_IN", + value: -123456789.068, + expValue: "-१२,३४,५६,७८९.०६८", + comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>" + } + ]); + + genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [ + + { attrs: {Currency: "EGP", lang: "ar-eg"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: "123456789.46", + expValue: "ج.م.\u200F 123٬456٬789٫46", + comment: "" + }, + { attrs: {Currency: "EGP", lang: "ar-eg"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: "-123456789.46", + expValue: "ج.م.\u200F 123٬456٬789٫46-", + comment: "" + }, + + { attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: "123456789.46", + expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦", + comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + }, + { attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: "-123456789.46", + expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦-", + comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + } + ]); + + genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [ + + { attrs: {Currency: "EGP", lang: "ar-eg"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: 123456789.46, + expValue: "ج.م.\u200F 123٬456٬789٫46", + comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + }, + { attrs: {Currency: "EGP", lang: "ar-eg"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: -123456789.46, + expValue: "ج.م.\u200F 123٬456٬789٫46-", + comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + }, + + { attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: 123456789.46, + expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦", + comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + }, + { attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"}, + desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>", + value: -123456789.46, + expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦-", + comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>" + } + ]); + + var testCases = []; + gen4DateFormat(testCases, "ar-eg", "ar_EG", "2005-07-31", + "31/7/2005", "", "31/07/2005", "", "31 يوليو, 2005", "", "الأحد, 31 يوليو, 2005", ""); + gen4DateFormat(testCases, "hi-in", "hi_IN", "2005-07-31", + "२००५-०७-३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "२००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "२००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "रविवार, २००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>"); + genFormatTestCases("Date Format", "dijit.form.DateTextBox", testCases); + + testCases = []; + gen4DateFormat(testCases, "ar-eg", "ar_EG", new Date(2005, 6, 31), + "31/7/2005", "", "31/07/2005", "", "31 يوليو, 2005", "", "الأحد, 31 يوليو, 2005", ""); + gen4DateFormat(testCases, "hi-in", "hi_IN", new Date(2005, 6, 31), + "२००५-०७-३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "२००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "२००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>", "रविवार, २००५ जुलाई ३१", "<a href='currency.html#cmt_3'>See #3 (currency.html).</a>"); + genValidateTestCases("Date Validate", "dijit.form.DateTextBox", testCases); + + dojo.parser.parse(); + + })(); + + </script> + </body> +</html> + +<!-- + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'short', localeDigit: true}" : "{formatLength:'short'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Short</b>", + value: date, + expValue: short, + comment: shortCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'medium', localeDigit: true}" : "{formatLength:'medium'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Medium</b>", + value: date, + expValue: medium, + comment: mediumCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'long', localeDigit: true}" : "{formatLength:'long'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Long</b>", + value: date, + expValue: long, + comment: longCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'full', localeDigit: true}" : "{formatLength:'full'}", lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Full</b>", + value: date, + expValue: full, + comment: fullCmt +--> + diff --git a/includes/js/dijit/tests/i18n/module.js b/includes/js/dijit/tests/i18n/module.js new file mode 100644 index 0000000..b484737 --- /dev/null +++ b/includes/js/dijit/tests/i18n/module.js @@ -0,0 +1,18 @@ +if(!dojo._hasResource["dijit.tests.i18n.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.tests.i18n.module"] = true; +dojo.provide("dijit.tests.i18n.module"); + +try{ + if(dojo.isBrowser){ + doh.registerUrl("dijit.tests.i18n.currency", dojo.moduleUrl("dijit", "tests/i18n/currency.html")); + doh.registerUrl("dijit.tests.i18n.date", dojo.moduleUrl("dijit", "tests/i18n/date.html")); + doh.registerUrl("dijit.tests.i18n.number", dojo.moduleUrl("dijit", "tests/i18n/number.html")); + doh.registerUrl("dijit.tests.i18n.textbox", dojo.moduleUrl("dijit", "tests/i18n/textbox.html")); + doh.registerUrl("dijit.tests.i18n.time", dojo.moduleUrl("dijit", "tests/i18n/time.html")); + doh.registerUrl("dijit.tests.i18n.digit", dojo.moduleUrl("dijit", "tests/i18n/digit.html")); + } +}catch(e){ + doh.debug(e); +} + +} diff --git a/includes/js/dijit/tests/i18n/number.html b/includes/js/dijit/tests/i18n/number.html new file mode 100644 index 0000000..0a1b717 --- /dev/null +++ b/includes/js/dijit/tests/i18n/number.html @@ -0,0 +1,136 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test NumberTextBox</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr']"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.NumberTextBox"); + dojo.require("dijit.form.CurrencyTextBox"); + dojo.require("dijit.form.DateTextBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test for Number</h1> + +<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button>--> + <p> + Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr". If not, convert these CLDR data and put them there. + </p> + + <script> + (function() { + + genFormatTestCases("Number Format", "dijit.form.NumberTextBox", [ + + { attrs: {lang: "zh-cn"}, + desc: "Locale: zh_CN", + value: "12345.067", + expValue: "12,345.067", + comment: "" + }, + { attrs: {lang: "zh-cn"}, + desc: "Locale: zh_CN", + value: "-12345.067", + expValue: "-12,345.067", + comment: "" + }, + + { attrs: {lang: "fr-fr"}, + desc: "Locale: fr_FR", + value: "12345.067", + expValue: "12 345,067", + comment: "" + }, + { attrs: {lang: "fr-fr"}, + desc: "Locale: zh_CN", + value: "-12345.067", + expValue: "-12 345,067", + comment: "" + } + ]); + + genValidateTestCases("Number Validate", "dijit.form.NumberTextBox", [ + + { attrs: {lang: "zh-cn"}, + desc: "Locale: zh_CN", + value: 12345.067, + expValue: "12,345.067", + comment: "" + }, + { attrs: {lang: "zh-cn"}, + desc: "Locale: zh_CN", + value: -12345.067, + expValue: "-12,345.067", + comment: "" + }, + + { attrs: {lang: "fr-fr"}, + desc: "Locale: fr_FR", + value: 12345.067, + expValue: "12 345,067", + comment: "" + }, + { attrs: {lang: "fr-fr"}, + desc: "Locale: zh_CN", + value: -12345.067, + expValue: "-12 345,067", + comment: "" + } + ]); + + dojo.parser.parse(); + + })(); + + </script> + </body> +</html> + + diff --git a/includes/js/dijit/tests/i18n/test_i18n.js b/includes/js/dijit/tests/i18n/test_i18n.js new file mode 100644 index 0000000..bc44e63 --- /dev/null +++ b/includes/js/dijit/tests/i18n/test_i18n.js @@ -0,0 +1,206 @@ +var validateValues = []; +var formatWidgetCount = 0; +var validateWidgetCount = 0; + +function getElementsById(id){ + var result = []; + + if(!id || typeof(id) != "string"){ + return result; + } + + var ae = document.getElementsByTagName(dojo.byId(id).tagName); + for(var i = 0; i < ae.length; i++){ + if(ae[i].id == id){ + result.push(ae[i]); + } + } + return result; +} + +function getString(n){ + return n && n.toString(); +} + +function startTest(t){ + startTestFormat(t); + startTestValidate(t); +} + +function escapeEx(s){ + var result = ""; + for(var i = 0; i < s.length; i++){ + var c = s.charAt(i); + switch (c){ + case '"': + result += '\\"'; + break; + case "'": + result += "\\'"; + break; + default: + result += escape(c); + break; + } + } + return result; +} + +function getAllTestCases(){ + var allTestCases = []; + for(var i = 0; i < formatWidgetCount; i++){ + allTestCases.push({ + name: "format-" + i, + runTest: new Function("t", "startTestFormat(" + i + ", t)") + }); + } + for(var i = 0; i < validateWidgetCount; i++){ + allTestCases.push({ + name: "validate-" + i, + runTest: new Function("t", "startTestValidate(" + i + ", t)") + }); + } + return allTestCases; +} + +function startTestFormat(i, t){ + var test_node = dojo.doc.getElementById("test_display_" + i); + var exp = dojo.doc.getElementById("test_display_expected_" + i).value; + var res_node = dojo.doc.getElementById("test_display_result_" + i); + res_node.innerHTML = test_node.value; + res_node.style.backgroundColor = (test_node.value == exp) ? "#AFA" : "#FAA"; + res_node.innerHTML += " <a style='font-size:0.8em' href='javascript:alert(\"Expected: " + escapeEx(exp) + "\\n Result: " + escapeEx(test_node.value) + "\")'>Compare (Escaped)</a>"; + t.is(exp, test_node.value); +} + +function startTestValidate(i, t){ + /* + * The dijit.byNode has an issue: cannot handle same id. + */ + var test_node = dojo.doc.getElementById("test_validate_" + i); + var inp_node = dojo.doc.getElementById("test_validate_input_" + i); + var exp = dojo.doc.getElementById("test_validate_expected_" + i).innerHTML; + var res_node = dojo.doc.getElementById("test_validate_result_" + i); + var val_node = dojo.doc.getElementById("test_display_value_" + i); + + test_node.value = inp_node.value; + /* + * The dijit.byNode has an issue. + */ + var widget = null; + var node = test_node; + while ((widget = dijit.byNode(node)) == null){ + node = node.parentNode; + if(!node){ + break; + } + } + + if(widget){ + widget.focus(); + + var expected = validateValues[i]; + var result = widget.getValue(); + if(validateValues[i].processValue){ + expected = validateValues[i].processValue(expected); + result = validateValues[i].processValue(result); + } + var parseCorrect = getString(expected) == getString(result); + val_node.style.backgroundColor = parseCorrect ? "#AFA" : "#FAA"; + val_node.innerHTML = getString(result) + (parseCorrect ? "" : "<br>Expected: " + getString(expected)); + + res_node.innerHTML = widget.isValid && !widget.isValid() ? "Wrong" : "Correct"; + res_node.style.backgroundColor = res_node.innerHTML == exp ? "#AFA" : "#FAA"; + + t.is(getString(expected), getString(result)); + } +} + +function genFormatTestCase(desc, dojoType, dojoAttrs, value, expValue, comment){ + dojo.doc.write("<tr>"); + dojo.doc.write("<td>" + desc + "</td>"); + dojo.doc.write("<td>"); + dojo.doc.write("<input id='test_display_" + formatWidgetCount + "' type='text' value='" + value + "' "); + dojo.doc.write("dojoType='" + dojoType + "' "); + for(var attr in dojoAttrs){ + dojo.doc.write(attr + "=\"" + dojoAttrs[attr] + "\" "); + } + dojo.doc.write("/>"); + dojo.doc.write("</td>"); + dojo.doc.write("<td><input id='test_display_expected_" + formatWidgetCount + "' value='" + expValue + "'></td>"); + dojo.doc.write("<td id='test_display_result_" + formatWidgetCount + "'></td>"); + dojo.doc.write("<td style='white-space:normal'>" + comment + "</td>"); + dojo.doc.write("</tr>"); + formatWidgetCount++; +} +/* +[ + {attrs: {currency: "CNY", lang: "zh-cn"}, desc: "", value:"-123456789.46", expValue: "", comment: ""}, + ... +] +*/ +function genFormatTestCases(title, dojoType, testCases){ + dojo.doc.write("<h2 class=testTitle>" + title + "</h2>"); + dojo.doc.write("<table border=1>"); + dojo.doc.write("<tr>"); + dojo.doc.write("<td class=title><b>Test Description</b></td>"); + dojo.doc.write("<td class=title><b>Test</b></td>"); + dojo.doc.write("<td class=title><b>Expected</b></td>"); + dojo.doc.write("<td class=title><b>Result</b></td>"); + dojo.doc.write("<td class=title><b>Comment</b></td>"); + dojo.doc.write("</tr>"); + + for(var i = 0; i < testCases.length; i++){ + var testCase = testCases[i]; + genFormatTestCase(testCase.desc, dojoType, testCase.attrs, testCase.value, testCase.expValue, testCase.comment); + } + + dojo.doc.write("</table>"); +} + +function genValidateTestCase(desc, dojoType, dojoAttrs, input, value, comment, isWrong){ + dojo.doc.write("<tr>"); + dojo.doc.write("<td>" + desc + "</td>"); + dojo.doc.write("<td>"); + dojo.doc.write("<input id='test_validate_" + validateWidgetCount + "' type='text' "); + dojo.doc.write("dojoType='" + dojoType + "' "); + for(var attr in dojoAttrs){ + dojo.doc.write(attr + "=\"" + dojoAttrs[attr] + "\" "); + } + dojo.doc.write("/>"); + dojo.doc.write("</td>"); + dojo.doc.write("<td><input id='test_validate_input_" + validateWidgetCount + "' value='" + input + "'></td>"); + dojo.doc.write("<td id='test_display_value_" + validateWidgetCount + "'></td>"); + dojo.doc.write("<td id='test_validate_expected_" + validateWidgetCount + "'>" + (isWrong ? "Wrong" : "Correct") + "</td>"); + dojo.doc.write("<td id='test_validate_result_" + validateWidgetCount + "'></td>"); + dojo.doc.write("<td style='white-space:normal'>" + comment + "</td>"); + dojo.doc.write("</tr>"); + validateValues.push(value); + validateWidgetCount++; +} +/* +[ + {attrs: {currency: "CNY", lang: "zh-cn"}, desc: "", value:false, expValue: "-123456789.46", comment: ""}, + ... +] +*/ +function genValidateTestCases(title, dojoType, testCases){ + dojo.doc.write("<h2 class=testTitle>" + title + "</h2>"); + dojo.doc.write("<table border=1>"); + dojo.doc.write("<tr>"); + dojo.doc.write("<td class=title><b>Test Description</b></td>"); + dojo.doc.write("<td class=title><b>Test</b></td>"); + dojo.doc.write("<td class=title><b>Input</b></td>"); + dojo.doc.write("<td class=title><b>Parsed Value</b></td>"); + dojo.doc.write("<td class=title><b>Expected</b></td>"); + dojo.doc.write("<td class=title><b>Result</b></td>"); + dojo.doc.write("<td class=title><b>Comment</b></td>"); + dojo.doc.write("</tr>"); + + for(var i = 0; i < testCases.length; i++){ + var testCase = testCases[i]; + genValidateTestCase(testCase.desc, dojoType, testCase.attrs, testCase.expValue, testCase.value, testCase.comment, testCase.isWrong); + } + + dojo.doc.write("</table>"); +} diff --git a/includes/js/dijit/tests/i18n/textbox.html b/includes/js/dijit/tests/i18n/textbox.html new file mode 100644 index 0000000..573496e --- /dev/null +++ b/includes/js/dijit/tests/i18n/textbox.html @@ -0,0 +1,173 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test TextBox</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.NumberTextBox"); + dojo.require("dijit.form.CurrencyTextBox"); + dojo.require("dijit.form.DateTextBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test</h1> + +<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button>--> + + <script> + (function() { + genFormatTestCases("Natural Language Casing Mapping", "dijit.form.TextBox", [ + + { attrs: {uppercase: "true"}, + desc: "Upper casing: Basic Latin", + value: "abcdefghijklmnopqrstuvwxyz", + expValue: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + comment: "" + }, + + { attrs: {uppercase: "true"}, + desc: "Upper casing: Latin with accents", + value: "àáâãäåæçèéêëìíîïðñòóôõö", + expValue: "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ", + comment: "" + }, + + { attrs: {uppercase: "true"}, + desc: "Upper casing: Turkish", + value: "ıi", + expValue: "Iİ", + comment: "<a href='#cmt_1'>See #1.</a>" + }, + + { attrs: {uppercase: "true"}, + desc: "Upper casing: Russian", + value: "абвгдежз", + expValue: "АБВГДЕЖЗ", + comment: "" + }, + + { attrs: {uppercase: "true"}, + desc: "Upper casing: German", + value: "ß", + expValue: "SS", + comment: "<a href='#cmt_1'>See #1.</a>" + }, + + { attrs: {lowercase: "true"}, + desc: "Lower casing: Turkish", + value: "Iİ", + expValue: "ıi", + comment: "<a href='#cmt_1'>See #1.</a>" + }, + + { attrs: {propercase: "true"}, + desc: "Title/Proper casing: Latin", + value: "\u01F1abc", + expValue: "\u01F2abc", + comment: "<a href='#cmt_1'>See #1.</a>" + } + ]); + + genFormatTestCases("White-space Detecting", "dijit.form.TextBox", [ + + { attrs: {trim: "true"}, + desc: "Normal space & tab", + value: " abc\t\t\t", + expValue: "abc", + comment: "" + }, + + { attrs: {trim: "true"}, + desc: "NO-BREAK SPACE", + value: "\u00A0abc\u00A0", + expValue: "abc", + comment: "Failed in IE. <a href='#cmt_2'>See #2.</a>" + }, + + { attrs: {trim: "true"}, + desc: "EN QUAD", + value: "\u2000abc\u2000", + expValue: "abc", + comment: "Failed in IE. <a href='#cmt_2'>See #2.</a>" + }, + + { attrs: {trim: "true"}, + desc: "IDEOGRAPHIC SPACE", + value: "\u3000abc\u3000", + expValue: "abc", + comment: "Failed in IE. <a href='#cmt_2'>See #2.</a>" + } + + + ]); + + dojo.parser.parse(); + + })(); + </script> + + <h2 class="testTitle">Issues & Comments </h2> + <a name="cmt_1"><h3 class="testTitle">Issue #1 <sup style="color:red">Not fixed. Avoid using this function of TextBox.</sup></h3></a> + <p> + Strictly speaking, all casing manipulation must use ICU case mapping rules (routine). However, the default JavaScript routines used by Dojo + do not support ICU case mapping rules in all browsers. + </p> + + <a name="cmt_2"><h3 class="testTitle">Issue #2 <sup style="color:red">Not fixed. Avoid using this function of TextBox.</sup></h3></a> + <p> + Trimming must get rid of all Unicode characters with the white space property. However, the default JavaScript routines used by Dojo + do not support get character properties in some browsers like IE. Other browsers like Firefox might support trimming more white space + characters. + </p> + + </body> +</html> + + diff --git a/includes/js/dijit/tests/i18n/time.html b/includes/js/dijit/tests/i18n/time.html new file mode 100644 index 0000000..0a972b9 --- /dev/null +++ b/includes/js/dijit/tests/i18n/time.html @@ -0,0 +1,207 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Test TextBox for Time</title> + + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp','ar-eg','ru-ru','hi-in','en-us']"></script> + <script type="text/javascript" src="../../../dojo/currency.js"></script> + <script type="text/javascript" src="../../../dojo/number.js"></script> + <script type="text/javascript"> + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dojo.date.locale"); + dojo.require("dojo.date.stamp"); + dojo.require("dojo.date"); + dojo.require("dojo.string"); + dojo.require("dojo.parser"); // scan page for widgets and instantiate them + dojo.require("doh.runner"); + </script> + <script src="test_i18n.js"></script> + <script type="text/javascript"> + dojo.addOnLoad(function(){ + doh.register("t", getAllTestCases()); + doh.run(); + }); + </script> + + <style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../themes/tundra/tundra.css"; + @import "../css/dijitTests.css"; + + .title { + background-color:#ddd; + } + + .hint { + background-color:#eee; + } + + .testExample { + background-color:#fbfbfb; + padding:1em; + margin-bottom:1em; + border:1px solid #bfbfbf; + } + + .dojoTitlePaneLabel label { + font-weight:bold; + } + + td {white-space:nowrap} + </style> + <script> + dojo.declare( + "dijit.form.TimeTextBox", + dijit.form.ValidationTextBox, + { + regExpGen: dojo.date.locale.regexp, + format: dojo.date.locale.format, + parse: dojo.date.locale.parse, + value: new Date() + } + ); + + var tz_s = dojo.date.getTimezoneName(new Date()); + if (!tz_s) { + var offset = new Date().getTimezoneOffset(); + var tz = [ + (offset <= 0 ? "+" : "-"), + dojo.string.pad(Math.floor(Math.abs(offset) / 60), 2), + dojo.string.pad(Math.abs(offset) % 60, 2) + ]; + tz.splice(0, 0, "GMT"); + tz.splice(3, 0, ":"); + tz_s = tz.join(""); + } + + function gen4DateFormat(testCases, language, locale, date, short, shortCmt, medium, mediumCmt, long, longCmt, full, fullCmt) { + var tz_l = language.indexOf("hi") == 0 && dojo.number.normalizeDigitChars ? + dojo.number.normalizeDigitChars(tz_s, language) : tz_s; + + short = short.replace(/UTC/, tz_l); + medium = medium.replace(/UTC/, tz_l); + long = long.replace(/UTC/g, tz_l); + full = full.replace(/UTC/, tz_l); + + var shortDate = null; + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'short', selector:'time', localeDigit:true}" : "{formatLength:'short', selector:'time'}", + lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Short</b>", + value: typeof(date) == "string" ? date : shortDate = new Date(date.getYear(), date.getMonth(), date.getDay() - 5, date.getHours(), date.getMinutes()), + expValue: short, + comment: shortCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'medium', selector:'time', localeDigit:true}" : "{formatLength:'medium', selector:'time'}", + lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Medium</b>", + value: date, + expValue: medium, + comment: mediumCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'long', selector:'time', localeDigit:true}" : "{formatLength:'long', selector:'time'}", + lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Long</b>", + value: date, + expValue: long, + comment: longCmt + }); + testCases.push({ + attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'full', selector:'time', localeDigit:true}" : "{formatLength:'full', selector:'time'}", + lang: language}, + desc: "Locale: <b>" + locale + "</b> Format: <b>Full</b>", + //value: typeof(date) == "string" || language.indexOf("fr") ? date : shortDate, + value: date, + expValue: full, + comment: fullCmt + }); + + date.processValue = function (value) { + return value ? new Date(1970, 0, 1, value.getHours(), value.getMinutes(), value.getSeconds()) : value; + }; + if (shortDate) { + shortDate.processValue = date.processValue; + } + } + </script> + </head> + + <body class="tundra"> + <h1 class="testTitle">Dijit TextBox Globalization Test for Time</h1> + + <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2> + <button id="startButton" onclick="startTest()">Start Test</button> + <p> + Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", "ja-jp", "ru-ru", "hi-in", "en-us" and "ar-eg". If not, convert these CLDR data and put them there. + </p> + + <script> + (function() { + var testCases = []; + gen4DateFormat(testCases, "ru-ru", "ru_RU", "1970-01-01T15:25:35", + "15:25", "", "15:25:35", "", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "zh-cn", "zh_CN", "1970-01-01T15:25:35", + "下午3:25", "", "下午03:25:35", "", "下午03时25分35秒", "", "下午03时25分35秒 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "en-us", "en_US", "1970-01-01T15:25:35", + "3:25 PM", "", "3:25:35 PM", "", "3:25:35 PM UTC", "<a href='#cmt_1'>See #1.</a>", "3:25:35 PM UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "fr-fr", "fr_FR", "1970-01-01T15:25:35", + "15:25", "", "15:25:35", "", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "ja-jp", "ja_JP", "1970-01-01T15:25:35", + "15:25", "", "15:25:35", "", "15:25:35:UTC", "<a href='#cmt_1'>See #1.</a>", "15時25分35秒UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "ar-eg", "ar_EG", "1970-01-01T15:25:35", + "3:25 \u0645", "", "3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "hi-in", "hi_IN", "1970-01-01T15:25:35", + "१५:२५", "<a href='#cmt_2'>See #2.</a>", "१५:२५:३५", "<a href='#cmt_2'>See #2.</a>", "१५:२५:३५ UTC", "<a href='#cmt_1'>See #1.</a> <a href='#cmt_2'>See #2.</a>", "१५:२५:३५ UTC", "<a href='#cmt_1'>See #1.</a> <a href='#cmt_2'>See #2.</a>"); + genFormatTestCases("Time Format", "dijit.form.TimeTextBox", testCases); + + testCases = []; + gen4DateFormat(testCases, "ru-ru", "ru_RU", new Date(1970, 0, 1, 15, 25, 35), + "15:25", "", "15:25:35", "", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "zh-cn", "zh_CN", new Date(1970, 0, 1, 15, 25, 35), + "下午3:25", "<a href='#cmt_3'>See #3.</a>", "下午03:25:35", "<a href='#cmt_3'>See #3.</a>", "下午03时25分35秒", "<a href='#cmt_3'>See #3.</a>", "下午03时25分35秒 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "en-us", "en_US", new Date(1970, 0, 1, 15, 25, 35), + "3:25 PM", "", "3:25:35 PM", "", "3:25:35 PM UTC", "<a href='#cmt_1'>See #1.</a>", "3:25:35 PM UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "fr-fr", "fr_FR", new Date(1970, 0, 1, 15, 25, 35), + "15:25", "", "15:25:35", "", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>", "15:25:35 UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "ja-jp", "ja_JP", new Date(1970, 0, 1, 15, 25, 35), + "15:25", "", "15:25:35", "", "15:25:35:UTC", "<a href='#cmt_1'>See #1.</a>", "15時25分35秒UTC", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "ar-eg", "ar_EG", new Date(1970, 0, 1, 15, 25, 35), + "3:25 \u0645", "", "3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "<a href='#cmt_1'>See #1.</a>"); + gen4DateFormat(testCases, "hi-in", "hi_IN", new Date(1970, 0, 1, 15, 25, 35), + "१५:२५", "<a href='#cmt_2'>See #2.</a>", "१५:२५:३५", "<a href='#cmt_2'>See #2.</a>", "१५:२५:३५ UTC", "<a href='#cmt_1'>See #1.</a> <a href='#cmt_2'>See #2.</a>", "१५:२५:३५ UTC", "<a href='#cmt_1'>See #1.</a> <a href='#cmt_2'>See #2.</a>"); + genValidateTestCases("Time Validate", "dijit.form.TimeTextBox", testCases); + + dojo.parser.parse(); + })(); + </script> + + <h2 class="testTitle">Issues & Comments</h2> + <h3 class="testTitle"><a name="cmt_1">Issue #1 <sup style="color:blue">Fixed</sup></a></h3> + <p> + Currently Dojo do not support parsing for most "long" and "full" time format which have a timezone mark in it. + </p> + + <h3 class="testTitle"><a name="cmt_2">Issue #2 <sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3> + <p> + Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi. + For example, ICU formats a number data into Indic number characters by default in the Arabic locale. + However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser). + </p> + + <h3 class="testTitle"><a name="cmt_3">Issue #3 <sup style="color:blue">Fixed</sup></a></h3> + <p> + This defect only occurs on the "zh-cn" locale. Dojo accepts "下午"(pm) in the textbox, but it automatically changes it to + "上午"(am) after the focus changed. The date value of the textbox is also changed. + </p> + <p> + The root cause of this issue is that the parser method's code assumes am/pm symbol always appears after the hour value. + But this is not true, for example, the pattern for "zh-cn" puts am/pm field before all the other fields. + </p> + </body> +</html> + |