Some of the jquery plugins we rely on offer the ability to include locale / culture files so that non-user users feel at home with their functionality (e.g. jquery-globalize and bootstrap-datapicker).
The old school way of achieving this was as follows (where "en-AU" is defined "on the fly", sometimes resulting in 404 for missing cultures):
<script type="text/javascript" src="/js/globalize/globalize.js"></script> <script type="text/javascript" src="/js/globalize/cultures/globalize.culture.en-AU.js"></script>
Is there a recommended way to achieve this using requirejs (note that globalization is included as a pad)?
Here is my first attempt, not yet sure how optomizer requirejs will handle this ...
Globalize = require("globalize"); ... locale = module.config().locale; if (locale != null) { require(["globalize/globalize.culture." + locale], function() { logger.debug("Loaded locale '" + locale + "'"); Globalize.culture(locale); }, function() { logger.debug("Unable to load locale '" + locale + "'"); }); }
edit: the optimizer does an excellent job of this, but the solution doesnβt actually work, because the culture file is loaded asynchronously, maybe the application used globalization before installing the culture.
source share