Moment.js, mockup, locales

AFAICT, Mockup does not ship/bundle moment.js locales in structure.js or plone.js.

Considering the cost of shipping all locales to a browser (47k+ gzipped), this makes sense.

I am curious how one would support the moment pattern l10n/i18n for non-default locales? It might be sensible to ship configuration for just detected language, but there are some tricky aspects here:

  1. Cannot serve moment locales as JSON (e.g. inside HTML data- attribute), as locales are JS not reducible to JSON.

  2. It may be desirable to have browser get a locale script for just the preferred locale detected by server (via zope.publisher.browser.BrowserLangauges, which works more correctly than ZPublisher does in parsing region in ACCEPT_LANGUAGES). But how would/should such a script be included on the page?

For the record: largest locale script in moment is 6.5k (1.93k gzipped).



1 Like