Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2401] iOS: Several localization enhancements

GitHub Issuen/a
TypeNew Feature
Resolution Date2011-04-17T01:59:00.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M02
Labelsfeature, ios, iphone, release-1.6.0
ReporterBill Dawson
AssigneeStephen Tramer


See #1870 for the initial, Android implementation directives from our customer.

Add to Ti.Locale:

getCurrentLanguage() - returns language string such as "en".

getCurrentCountry() - returns "US" for example.

getCurrentLocale() - returns "en-US" for example.

getCurrencyCode(locale_string) - e.g., pass "en-US" and it will return "USD"

getCurrencySymbol(currency_code) - e.g., pass "USD" and it will return "$"

getLocaleCurrencySymbol(locale_string) - e.g., pass "en-US" and it will return "$"

Locale and format string support for String.formatDecimal:

String.formatDecimal(2.5) - returns 2.5 formatted in current locale. If a european locale, for example, will return "2,5".

String.formatDecimal(2.5, "000.000") - e.g., returns "002.500" if current locale is en_US, or "002,500" if current locale is de_AT.

String.formatDecimal(2.5, 'de-AT') - returns "2,5"

String.formatDecimal(2.5, 'de-AT', '000.0000') - returns "002,50000"

You can exercise these with this simple program (app.js):

/*global Ti, Titanium, alert, JSON */
var win = Titanium.UI.createWindow({  
    fullscreen: true,
    exitOnClose: true

var rows = [];
function makeRow(title) {
    rows.push(Ti.UI.createTableViewRow({title: title}));

var statements = 
     'String.formatDecimal(2.5, "000.00")',
     'String.formatDecimal(2.5, "de-DE")',
     'String.formatDecimal(2.5, "de-DE", "000.00")'
for (var i = 0; i < statements.length; i++) {
    makeRow(statements[i] + " = " + eval(statements[i]));




  1. Bill Dawson 2011-04-15

    NOTE: I put a locale.js test suite into the drillbit/tests folder. It's okay that it won't pass for iOS (based on Ralf's comment in his e-mail, namely all tests must pass except "tests for features or bugs not scheduled for the next release. For example I don't want to slow down test creation.") Since we're not sure yet when this feature will be scheduled, this rule applies.

  2. Bill Dawson 2011-04-15

    I decided to go ahead and do the api doc additions for the #1870 changes; I just know I'd never get around to it otherwise, and I didn't want you guys to have to do it. I marked them Android Only, so if you do get this into 1.5, be sure to just open apidoc/Titanium/Locale/Locale.tdoc and search for 'Android' and take out those comments.

  3. Jeff Haynie 2011-04-15

    (from [5d84d4aaa3503788da996a4f7846f60c31255f28]) [#2401 state:fixed-in-qa] Localization enhancements for iOS. https://github.com/appcelerator/titanium_mobile/commit/5d84d4aaa3503788da996a4f7846f60c31255f28"> https://github.com/appcelerator/titanium_mobile/commit/5d84d4aaa350...

  4. Thomas Huelbert 2011-04-15

    [INFO] Titanium SDK version: 1.6.0 (01/12/11 09:38 db09d1e) 4GT ipod touch, 3G iphone 3.1.3. English and Spanish checked for langs, and usa and japan checked for locale. moved test to QATests

JSON Source