Skip to content
This repository was archived by the owner on Jun 25, 2019. It is now read-only.

Commit 3db0478

Browse files
author
Felix Gladisch
committed
feat: angular 4 and ngx-translate
1 parent 9a1aa62 commit 3db0478

14 files changed

+105
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Node files
88
/node_modules
99
npm-debug.log
10+
yarn.lock
1011

1112
# OS generated files
1213
.DS_Store

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
[![Build Status](https://travis-ci.org/fgladisch/angular2-webpack-seed.svg?branch=master)](https://travis-ci.org/fgladisch/angular2-webpack-seed)
44

5-
This is a minimalistic Angular 2 seed project, featuring:
6-
* [TypeScript 2.1](https://www.typescriptlang.org)
5+
This is a minimalistic Angular 2+ seed project, featuring:
6+
* [TypeScript 2.2](https://www.typescriptlang.org)
77
* [Sass](http://sass-lang.com)
88
* [Bootstrap 4](http://v4-alpha.getbootstrap.com)
99
* [ng-bootstrap](https://github.com/ng-bootstrap/ng-bootstrap)
10-
* [ng2-translate](https://github.com/ocombe/ng2-translate)
10+
* [ngx-translate](https://github.com/ngx-translate)
1111
* [webpack](https://webpack.github.io)
1212
* [Karma](https://karma-runner.github.io)
1313
* [Jasmine](http://jasmine.github.io)
1414
* [@types](https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files)
1515

16-
This seed follows the [Angular 2 Style Guide](https://angular.io/docs/ts/latest/guide/style-guide.html).
16+
This seed follows the [Angular Style Guide](https://angular.io/docs/ts/latest/guide/style-guide.html).
1717

1818
## How to use
1919

@@ -46,3 +46,6 @@ Production files are located in `dist`.
4646
```bash
4747
npm run build
4848
```
49+
50+
# License
51+
[MIT](/LICENSE)

config/karma.conf.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module.exports = function (config) {
77
// base path that will be used to resolve all patterns (e.g. files, exclude)
88
basePath: '',
99

10+
// Karma will require() these plugins
11+
plugins: [
12+
"karma-jasmine",
13+
"karma-mocha-reporter",
14+
"karma-phantomjs-launcher",
15+
"karma-sourcemap-loader",
16+
"karma-webpack"
17+
],
18+
1019
/*
1120
* Frameworks to use
1221
*

config/webpack.common.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ module.exports = function() {
1010
return {
1111

1212
resolve: {
13-
// Array of extensions that will be used to resolve modules
14-
extensions: ['.js', '.ts']
13+
extensions: ['.ts', '.js', '.json'],
14+
modules: [
15+
helpers.root('src'),
16+
helpers.root('node_modules')
17+
],
1518
},
1619

1720
// Entry points the bundles
@@ -71,9 +74,9 @@ module.exports = function() {
7174
name: ['app', 'vendor', 'polyfills']
7275
}),
7376
// Provides context to Angular's use of System.import
77+
// See: https://github.com/AngularClass/angular2-webpack-starter/issues/993#issuecomment-283423040
7478
new ContextReplacementPlugin(
75-
// The (\\|\/) piece accounts for path separators in *nix and Windows
76-
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
79+
/angular(\\|\/)core(\\|\/)@angular/,
7780
helpers.root('src')
7881
),
7982
// Generates an HTML5 file that includes all webpack bundles

config/webpack.test.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,17 @@ module.exports = {
1111
devtool: 'inline-source-map',
1212

1313
resolve: {
14-
extensions: ['.ts', '.js'],
14+
extensions: ['.ts', '.js', '.json'],
1515
modules: [
16-
path.resolve(__dirname, 'src'),
17-
'node_modules'
18-
]
16+
helpers.root('src'),
17+
helpers.root('node_modules')
18+
],
1919
},
2020

2121
module: {
22+
exprContextCritical: false,
2223
// See webpack.common.js for more explanation about rules
2324
rules: [
24-
// Extracts SourceMaps for source files that as added as sourceMappingURL comment
25-
{
26-
enforce: 'pre',
27-
test: /\.js$/,
28-
loader: 'source-map-loader',
29-
exclude: [
30-
// These packages have problems with their sourcemaps
31-
helpers.root('node_modules/rxjs'),
32-
helpers.root('node_modules/@angular'),
33-
helpers.root('node_modules/@ng-bootstrap'),
34-
helpers.root('node_modules/ng2-translate')
35-
]
36-
},
3725
{
3826
test: /\.ts$/,
3927
loaders: ['awesome-typescript-loader?silent=true', 'angular2-template-loader']
@@ -55,8 +43,9 @@ module.exports = {
5543

5644
// See webpack.common.js for more explanation about plugins
5745
plugins: [
46+
// Provides context to Angular's use of System.import
5847
new ContextReplacementPlugin(
59-
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
48+
/angular(\\|\/)core(\\|\/)@angular/,
6049
helpers.root('src')
6150
),
6251
new webpack.DefinePlugin({

package.json

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-webpack-seed",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"scripts": {
55
"start": "webpack-dev-server --inline --progress --port 3000",
66
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail",
@@ -22,51 +22,50 @@
2222
"url": "https://github.com/fgladisch/angular2-webpack-seed/issues"
2323
},
2424
"dependencies": {
25-
"@angular/common": "2.4.7",
26-
"@angular/compiler": "2.4.7",
27-
"@angular/core": "2.4.7",
28-
"@angular/forms": "2.4.7",
29-
"@angular/http": "2.4.7",
30-
"@angular/platform-browser": "2.4.7",
31-
"@angular/platform-browser-dynamic": "2.4.7",
32-
"@angular/router": "3.4.7",
33-
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.20",
25+
"@angular/common": "4.0.1",
26+
"@angular/compiler": "4.0.1",
27+
"@angular/core": "4.0.1",
28+
"@angular/forms": "4.0.1",
29+
"@angular/http": "4.0.1",
30+
"@angular/platform-browser": "4.0.1",
31+
"@angular/platform-browser-dynamic": "4.0.1",
32+
"@angular/router": "4.0.1",
33+
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.22",
34+
"@ngx-translate/core": "6.0.1",
35+
"@ngx-translate/http-loader": "0.0.3",
3436
"bootstrap": "4.0.0-alpha.6",
3537
"core-js": "2.4.1",
36-
"ie-shim": "0.1.0",
37-
"ng2-translate": "5.0.0",
38-
"rxjs": "5.1.0",
39-
"zone.js": "0.7.6"
38+
"rxjs": "5.2.0",
39+
"zone.js": "0.8.5"
4040
},
4141
"devDependencies": {
42-
"@types/core-js": "0.9.35",
43-
"@types/jasmine": "2.5.41",
44-
"@types/node": "7.0.5",
42+
"@types/core-js": "0.9.40",
43+
"@types/jasmine": "2.5.47",
44+
"@types/node": "7.0.12",
4545
"angular2-template-loader": "0.6.2",
46-
"awesome-typescript-loader": "3.0.3",
46+
"awesome-typescript-loader": "3.1.2",
4747
"copy-webpack-plugin": "4.0.1",
48-
"css-loader": "0.26.1",
49-
"extract-text-webpack-plugin": "2.0.0-rc.3",
50-
"file-loader": "0.10.0",
51-
"html-loader": "0.4.4",
48+
"css-loader": "0.28.0",
49+
"extract-text-webpack-plugin": "2.1.0",
50+
"file-loader": "0.10.1",
51+
"html-loader": "0.4.5",
5252
"html-webpack-plugin": "2.28.0",
5353
"jasmine-core": "2.5.2",
5454
"json-loader": "0.5.4",
55-
"karma": "1.3.0",
55+
"karma": "1.5.0",
5656
"karma-jasmine": "1.1.0",
57-
"karma-mocha-reporter": "2.2.2",
58-
"karma-phantomjs-launcher": "1.0.2",
57+
"karma-mocha-reporter": "2.2.3",
58+
"karma-phantomjs-launcher": "1.0.4",
5959
"karma-sourcemap-loader": "0.3.7",
60-
"karma-webpack": "2.0.2",
61-
"node-sass": "4.5.0",
60+
"karma-webpack": "2.0.3",
61+
"node-sass": "4.5.2",
6262
"raw-loader": "0.5.1",
63-
"rimraf": "2.5.4",
64-
"sass-loader": "5.0.1",
65-
"source-map-loader": "0.1.6",
63+
"rimraf": "2.6.1",
64+
"sass-loader": "6.0.3",
6665
"ts-helpers": "1.1.2",
67-
"typescript": "2.1.6",
68-
"webpack": "2.2.1",
69-
"webpack-dev-server": "2.3.0",
70-
"webpack-merge": "2.6.1"
66+
"typescript": "2.2.2",
67+
"webpack": "2.3.2",
68+
"webpack-dev-server": "2.4.2",
69+
"webpack-merge": "4.1.0"
7170
}
7271
}

src/app/app.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { TestBed, inject, ComponentFixture } from '@angular/core/testing';
2-
import { TranslateModule, TranslateService } from 'ng2-translate/ng2-translate';
32
import { BrowserModule } from '@angular/platform-browser';
43
import { APP_BASE_HREF } from '@angular/common';
54
import { RouterModule } from '@angular/router';
5+
import { TranslateModule, TranslateService } from '@ngx-translate/core';
66
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
77

88
import { NavigationComponent } from './navigation';

src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ViewEncapsulation } from '@angular/core';
2-
import { TranslateService } from 'ng2-translate/ng2-translate';
2+
import { TranslateService } from '@ngx-translate/core';
33

44
@Component({
55
selector: 'app',
@@ -14,7 +14,7 @@ export class AppComponent {
1414
}
1515

1616
initializeLanguage() {
17-
let browserLang: string = this.translate.getBrowserLang();
17+
const browserLang: string = this.translate.getBrowserLang();
1818
this.translate.setDefaultLang('en');
1919
this.translate.use(browserLang);
2020
}

src/app/app.module.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { HttpModule } from '@angular/http';
3+
import { HttpModule, Http } from '@angular/http';
44
import { FormsModule } from '@angular/forms';
5-
import { TranslateModule } from 'ng2-translate/ng2-translate';
65
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
6+
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
7+
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
78

89
import { AppComponent } from './app.component';
910
import { routing } from './app.routing';
@@ -24,7 +25,15 @@ import { NavigationComponent } from './navigation';
2425
HttpModule,
2526
FormsModule,
2627
NgbModule.forRoot(),
27-
TranslateModule.forRoot(),
28+
TranslateModule.forRoot({
29+
loader: {
30+
provide: TranslateLoader,
31+
useFactory: (http: Http) => {
32+
return new TranslateHttpLoader(http, './i18n/', '.json');
33+
},
34+
deps: [Http]
35+
}
36+
}),
2837
routing
2938
]
3039
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.navbar-brand {
22
img {
3-
height: 30px;
3+
height: 28px;
44
}
55
}

0 commit comments

Comments
 (0)