appcelerator/alloy — pull request #166 by xavierlacot (2013-06-28 16:01:21+00:00)
Title: Update momentjs builtin to the last available version, and make translations available

This PR addresses the problem described here: https://jira.appcelerator.org/browse/ALOY-726

Apart from updating momentjs to the version 2.0.0, it also embeds all the localization files. These files get automatically embedded in an Alloy-app build if the project uses momentjs (indeed, only the localizations required by the project are automatically embedded). Moreover, momentjs's language defaults to Ti.Locale.currentLocale.

In a controller, the builtin momentjs is still required the same way like before:

var moment = require('alloy/moment');

It is possible to force a language by switching it:

var moment = require('alloy/moment');
moment.lang('fr');
// momentjs now uses the french localization

The embedded localizations are the one which match the directory names under the "i18n" folder of the Titanium project. In case an app would require another localization, a manuel require must be done:

// assume there is only a "fr" directory under "i18n"
var moment = require('alloy/moment');
require('alloy/moment/lang/bg');
moment.lang('bg');
// momentjs now uses the bulgarian localization