Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Last active January 3, 2016 02:39
Show Gist options
  • Save nikcorg/8397023 to your computer and use it in GitHub Desktop.
Save nikcorg/8397023 to your computer and use it in GitHub Desktop.
Localised Moment.js
{
"name": "moment-demo",
"version": "0.0.0",
"authors": [
"Niklas Lindgren <[email protected]>"
],
"description": "localisation inclusion demo",
"dependencies": {
"moment": "~2.5.0",
"requirejs": "~2.1.10"
}
}
<!doctype html>
<html>
<head>
<title>Moment localised</title>
<script src="bower_components/requirejs/require.js"></script>
<script>
require.config({
paths: {
"moment": "bower_components/moment/moment",
"moment-langs": "bower_components/moment/lang"
}
});
</script>
<script>
define("moment-fi", ["moment", "moment-langs/fi"], function (moment, fi) {
return moment;
});
require(["moment-fi"], function (moment) {
console.log( moment(Date.now()).calendar() );
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment