1

I'm wondering how to include one of the pre-defined momentjs locales in meteor, which normally resides in locales/*.js, but including this per the moment docs does not work in Meteor:

<script src="locale/pt.js"></script>

How would I include the pre-defined moment locales in Meteor?

1 Answers1

2

When external resources (javascript libraries, css, images, fonts) are needed, put them in public. So in your case, I would put the file in public/js/momentjs/locales/pt.js. Then, in the file containing my app's <head> (client/head.html in my case):

<head>
  <!-- etc -->
  <script src="/js/momentjs/locales/pt.js"></script>
</head>

All the resources you add in the head will end up being inserted in the head after all the ones from meteor packages, so no need to worry about load order.

SylvainB
  • 4,765
  • 2
  • 26
  • 39
  • Agreed, for actual libraries and features. But in the case of a simple momentjs locale file? Seems a bit over-the-line. In that case I would at least integrate it in a "translations" purposed package – SylvainB Jul 17 '15 at 16:37
  • Well, it would allow to include the locales not from a line in some HTML but from the `.meteor/packages` file, allowing it to be compiled and sent with the initial script load. Thinking about it, sending this locale on page load may not be what OP wants. – Kyll Jul 17 '15 at 16:41
  • I was actually looking for a way to include the pre-defined moment locales, however that has been answered as a separate question. Thank you for your interest. – Daniel Skogquist Åborg Jul 20 '15 at 13:57