{ "id": "62502", "key": "TIMOB-1870", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11228", "name": "Release 1.5.0 M03", "archived": true, "released": true, "releaseDate": "2010-11-29" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:24.000+0000", "created": "2011-04-15T03:04:22.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "feature", "rplist" ], "versions": [], "issuelinks": [], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2011-04-17T01:57:24.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}
Add to Ti.Locale:
\ngetCurrentLanguage()
- returns language string such\nas \"en\".
getCurrentCountry()
- returns \"US\" for example.
getCurrentLocale()
- returns \"en-US\" for\nexample.
getCurrencyCode(locale_string)
- e.g., pass \"en-US\"\nand it will return \"USD\"
getCurrencySymbol(currency_code)
- e.g., pass \"USD\"\nand it will return \"$\"
getLocaleCurrencySymbol(locale_string)
- e.g., pass\n\"en-US\" and it will return \"$\"
Locale and format string support for\nString.formatDecimal
:
String.formatDecimal(2.5)
- returns 2.5 formatted\nin current locale. If a european locale, for example, will return\n\"2,5\".
String.formatDecimal(2.5, \"000.000\")
- e.g.,\nreturns \"002.500\" if current locale is en_US, or \"002,500\" if\ncurrent locale is de_AT.
String.formatDecimal(2.5, 'de-AT')
- returns\n\"2,5\"
String.formatDecimal(2.5, 'de-AT', '000.0000')
-\nreturns \"002,50000\"
You can exercise these with this simple program (app.js):
\n\n/*global Ti, Titanium, alert, JSON */\nTitanium.UI.setBackgroundColor('#000');\nvar win = Titanium.UI.createWindow({ \n title:'Test',\n backgroundColor:'#fff',\n fullscreen: true,\n exitOnClose: true\n});\n\nvar rows = [];\nfunction makeRow(title) {\n rows.push(Ti.UI.createTableViewRow({title: title}));\n}\n\nvar statements = \n ['Ti.Locale.getCurrentLanguage()',\n 'Ti.Locale.getCurrentCountry()',\n 'Ti.Locale.getCurrentLocale()',\n 'Ti.Locale.getCurrencyCode(Ti.Locale.getCurrentLocale())',\n 'Ti.Locale.getCurrencyCode(\"en-GB\")',\n 'Ti.Locale.getCurrencyCode(\"-GB\")',\n 'Ti.Locale.getCurrencySymbol(\"EUR\")',\n 'Ti.Locale.getCurrencySymbol(\"GBP\")',\n 'Ti.Locale.getLocaleCurrencySymbol(\"en-US\")',\n 'String.formatDecimal(2.5)',\n 'String.formatDecimal(2.5, \"000.00\")',\n 'String.formatDecimal(2.5, \"de-DE\")',\n 'String.formatDecimal(2.5, \"de-DE\", \"000.00\")'\n ];\n \nfor (var i = 0; i < statements.length; i++) {\n makeRow(statements[i] + \" = \" + eval(statements[i]));\n}\n\nwin.add(Ti.UI.createTableView({data:rows}));\n\nwin.open();
\n
(from [11d5b5f2c891cbd6f3bd6620fc59e4db93ee7815])\n[#1870] More localization support including\ncurrency info and arguments to String.formatDecimal \nhttp://github.com/appcelerator/titanium_mobile/commit/11d5b5f2c891c...
Todo:
\nupdate api docs
\nticket for iOS guys
\nPer #2333's directive to use dash instead of\nunderscore, the examples above were changed. E.g., en_GB ->\nen-GB.
(from [f39a6cc5486745894e7f08afe740cb418c74f967])\n[#1870 state:fixed-in-qa] Document and unit test\nfor Ti.Locale enhancements; fix one place where underscore and dash\nwere swapped mistakenly. \nhttps://github.com/appcelerator/titanium_mobile/commit/f39a6cc54867...
(from [19a59fd7caded841d66bdaded43240332b90d76e])\n[#1870] Add one more sentence to the Locale.tdoc\n\nhttps://github.com/appcelerator/titanium_mobile/commit/19a59fd7cade...
pass Android 1.6 Titanium SDK version: 1.5.0 (11/24/10 12:05\nc0aff27)
\npass Android 2.1 Titanium SDK version: 1.5.0 (11/24/10 12:05\nc0aff27)