[TIMOB-23403] iOS: Debug exception when calling moment.locale(Ti.Locale.currentLocale)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2019-11-14T16:25:49.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | defect, iOS |
Reporter | Christy Thomas |
Assignee | Angel Petkov |
Created | 2016-05-12T13:54:32.000+0000 |
Updated | 2019-11-14T16:25:49.000+0000 |
Description
This is the line of code the exception is happening and name variable is "en-US", but we also use french as well and is the reason why we are calling moment.locale.
require("alloy/moment/lang/" + name);
Thread [kroll$1] (Suspended (exception at line 134 in moment.js))
loadLocale(name) [moment.js:134]
locale_locales__getLocale(key) [moment.js:163]
locale_locales__getSetGlobalLocale(key, values) [moment.js:142]
Controller() [index.js:43]
createController(name, args) [alloy.js:232]
[Top-level script] [app.js:3]
In Run mode this works fine and our date displays correctly for the locale. The example doesn't display date, but out app does.
I have attached example code to demonstrate this issue. Run the app in Debug mode.
Attachments
File | Date | Size |
---|---|---|
AlloyTestProjectMoment.zip | 2016-05-12T13:53:26.000+0000 | 8203637 |
[~cthomas] Hello, thank you for reporting the issue. It's currently being looked in to, for the time being you can use Titanium.Locale to get the currentLocal and language, which should return the same values.
I've found that it isn't worth the bother of trying to use the built-in distribution of moment if your app's distribution is likely to be in multiple locales and you won't have i18n translations onboard for all those locales. Instead, just head over to momentjs.com, download moment-with-locales.js and require it instead of the "alloy/moment" version... So in practice, I do the following in alloy.js:
And when I need to use it, simply use
or whatever...
Unable to reproduce the issue. Axway Appcelerator Studio, build: 5.1.4.201909061933 macOS : 10.15 Node.js Version : 8.9.1 npm Version : 5.5.1 Appcelerator CLI : 7.1.1 Titanium CLI CLI Version : 5.2.1 node-appc Version : 0.2.49 Titanium SDKs : 8.2.1.GA