Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not set locale with webpack #321

Open
yaoyonstudio opened this issue Feb 6, 2017 · 1 comment
Open

can not set locale with webpack #321

yaoyonstudio opened this issue Feb 6, 2017 · 1 comment

Comments

@yaoyonstudio
Copy link

Hi, guys, I really need some help.
I'm using angular 1.6, webpack and es6, I import moment and locale file , and did the configure as document said. but still can not set the locale lang.
Here's my code:

webpack.config.js:

process.env.NODE_ENV == 'production';
var debug = process.env.NODE_ENV !== 'production';
var webpack = require('webpack');
var path = require('path');

module.exports = {
    context: path.join(__dirname, 'src'),
    devtool: debug ? 'inline-sourcemap' : null,
    //devtool: null,
    entry: {
        app: [ './js/app.js' ],
        vendor: [ 'angular' ]
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015']
                }
            }
        ]
    },
    watch: true,
    output: {
        path: __dirname + '/src',
        filename: 'main.js'
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: "vendor",
            filename: "vendor.js",
            minChunks: Infinity
        })
    ]
};

index.html

<!DOCTYPE html>
<html ng-app="adwApp">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0">
    <title>angular-datepicker-webpack</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">    
</head>
<body>
<div date-picker class="orderDate" max-view="date" format="yyyy-MM-dd" min-view="date" view="date"></div>
<script src="vendor.js"></script>
<script src="main.js"></script>
</body>
</html>

app.js:

import angular from 'angular';
import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');

require('imports?this=>window,exports=>false,define=>false!angular-datepicker');

angular.module('adwApp', ['datePicker'])

qq 20170206213243

as you see, the locale setting not working

@DanTalash
Copy link
Contributor

DanTalash commented Feb 21, 2017

That's strange, as all locale related stuff is handled by moment. Try running moment.locale(); in your console after the page loads to verify that the locale is actually set to Chinese and didn't somehow get overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants