Git Product home page Git Product logo

ember-cli-moment-shim's Introduction

ember-cli-moment-shim

Build Status npm Version Ember Observer Score

ember-cli ES6 module shim for momentjs and moment timezone within your Ember applications. It will also conditionally bundle in specific locale/timezone data for those concerned about payload size.

Usage

  • ember install ember-cli-moment-shim
import moment from 'moment';

Features

  • ES6 accessible module for moment
  • Trim your build sizes by bundling locale & timezone data through simple configuration
  • FastBoot support

Enabling moment-timezone

// config/environment.js
module.exports = function(environment) {
  return {
    moment: {
      // Options:
      // 'all' - all years, all timezones
      // 'subset' - subset of the timezone data to cover 2010-2020 (or 2012-2022 as of 0.5.12). all timezones.
      // 'none' - no data, just timezone API
      includeTimezone: 'all'
    }
  };
}

i18n support

Cherry pick locales (optimal)

// config/environment.js
module.exports = function(environment) {
  return {
    moment: {
      // To cherry-pick specific locale support into your application.
      // Full list of locales: https://github.com/moment/moment/tree/master/locale
      includeLocales: ['es', 'fr-ca']
    }
  };

NOTE: English is bundled automatically โ€“ no need to add en in includeLocales

Include all locales

// config/environment.js
module.exports = function(environment) {
  return {
    moment: {
      includeLocales: true
    }
  };

Configure default runtime locale

// app/routes/applicaton.js
import moment from 'moment';

export default Ember.Route.extend({
  beforeModel() {
    // sets the application locale to Spanish
    moment.locale('es');
  }
});

Write all locales to a folder that is relative to dist

// config/environment.js
module.exports = function(environment) {
  return {
    moment: {
      // This will output _all_ locale scripts to assets/moment-locales
      // this option does not respect includeLocales
      localeOutputPath: 'assets/moment-locales'
    }
  };

The feature set for i18n support within moment can be found here: http://momentjs.com/docs/#/i18n/

License

ember-cli-moment-shim shims is MIT Licensed.

ember-cli-moment-shim's People

Contributors

jasonmit avatar greenkeeperio-bot avatar dnegstad avatar jrjohnson avatar loganrosen avatar seanpdoyle avatar abuiles avatar bartheleway avatar jherdman avatar jmurphyau avatar jacefarm avatar karlbecker avatar kybishop avatar nathanhammond avatar ncastro-nypr avatar rlivsey avatar turbo87 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.