File tree 8 files changed +59
-11
lines changed 8 files changed +59
-11
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export = (config: any) => {
11
11
12
12
karma . set ( {
13
13
files : [
14
+ { pattern : 'src/i18n/*.json' , included : false } ,
14
15
{ pattern : 'build/libs.js' , watched : false } ,
15
16
{ pattern : 'src/spec.module.js' } ,
16
17
] ,
@@ -25,6 +26,9 @@ export = (config: any) => {
25
26
} ) ;
26
27
27
28
config . set ( {
29
+ proxies : {
30
+ '/i18n' : '/base/src/i18n' ,
31
+ } ,
28
32
mime : {
29
33
'text/x-typescript' : [ 'ts' , 'tsx' ] ,
30
34
} ,
Original file line number Diff line number Diff line change 48
48
"@angular/platform-browser" : " 4.0.1" ,
49
49
"@angular/platform-browser-dynamic" : " 4.0.1" ,
50
50
"@angular/router" : " 4.0.1" ,
51
+ "@ngx-translate/core" : " 6.0.1" ,
52
+ "@ngx-translate/http-loader" : " 0.0.3" ,
51
53
"core-js" : " 2.4.1" ,
52
54
"rxjs" : " 5.3.0" ,
53
55
"tslib" : " 1.6.0" ,
Original file line number Diff line number Diff line change 1
1
import { AppComponent } from './app.component' ;
2
- import { TestBed } from '@angular/core/testing' ;
2
+ import { TestBed , ComponentFixture , async } from '@angular/core/testing' ;
3
3
import { NO_ERRORS_SCHEMA } from '@angular/core' ;
4
4
import { AppModule } from './app.module' ;
5
5
6
6
describe ( 'App component:' , ( ) => {
7
7
8
- beforeEach ( ( ) => {
8
+ let component : AppComponent ;
9
+ let fixture : ComponentFixture < AppComponent > ;
10
+
11
+ beforeEach ( async ( ( ) => {
9
12
TestBed . configureTestingModule ( {
10
13
imports : [ AppModule ] ,
11
14
schemas : [ NO_ERRORS_SCHEMA ]
12
- } ) ;
13
- } ) ;
14
-
15
- let component : AppComponent ;
15
+ } )
16
+ . compileComponents ( )
17
+ . then ( ( ) => {
18
+ fixture = TestBed . createComponent ( AppComponent ) ;
19
+ component = fixture . componentInstance ;
20
+ } ) ;
21
+ } ) ) ;
16
22
17
23
it ( 'smoke' , ( ) => {
18
- expect ( AppComponent ) . toBeDefined ( ) ;
24
+ expect ( component ) . toBeDefined ( ) ;
19
25
} ) ;
20
26
21
- it ( 'instance' , ( ) => {
22
- component = new AppComponent ( ) ;
27
+ it ( 'title property' , ( ) => {
23
28
expect ( component . title ) . toBe ( 'App' ) ;
24
29
} ) ;
25
30
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Component } from '@angular/core' ;
2
+ import { TranslateService } from '@ngx-translate/core' ;
2
3
3
4
@Component ( {
4
5
selector : 'app' ,
@@ -11,5 +12,11 @@ import { Component } from '@angular/core';
11
12
styleUrls : [ 'app.component.scss' ] ,
12
13
} )
13
14
export class AppComponent {
15
+
14
16
title = 'App' ;
17
+
18
+ constructor ( translate : TranslateService ) {
19
+ translate . setDefaultLang ( 'en' ) ;
20
+ translate . use ( 'en' ) ;
21
+ }
15
22
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { FormsModule } from '@angular/forms';
7
7
import { AppErrorHandler } from './app.errorhandler' ;
8
8
import { WelcomeComponent } from './welcome/welcome.component' ;
9
9
import { HomeComponent } from './home/home.component' ;
10
+ import { TranslationModule } from './translation.module' ;
10
11
11
12
const routes : Routes = [
12
13
{ path : '' , component : HomeComponent } ,
@@ -18,7 +19,8 @@ const routes: Routes = [
18
19
imports : [
19
20
BrowserModule ,
20
21
FormsModule ,
21
- RouterModule . forRoot ( routes )
22
+ RouterModule . forRoot ( routes ) ,
23
+ TranslationModule ,
22
24
] ,
23
25
declarations : [
24
26
AppComponent ,
Original file line number Diff line number Diff line change
1
+ import { Http , HttpModule } from '@angular/http' ;
2
+ import { TranslateModule , TranslateLoader } from '@ngx-translate/core' ;
3
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader' ;
4
+ import { NgModule } from '@angular/core' ;
5
+ import { BrowserModule } from '@angular/platform-browser' ;
6
+
7
+ // AoT requires an exported function for factories.
8
+ export function createTranslateLoader ( http : Http ) : TranslateHttpLoader {
9
+ return new TranslateHttpLoader ( http , 'i18n/' , '.json' ) ;
10
+ }
11
+
12
+ @NgModule ( {
13
+ imports : [
14
+ BrowserModule ,
15
+ HttpModule ,
16
+ TranslateModule . forRoot ( {
17
+ loader : {
18
+ provide : TranslateLoader ,
19
+ useFactory : createTranslateLoader ,
20
+ deps : [ Http ]
21
+ }
22
+ } )
23
+ ]
24
+ } )
25
+ export class TranslationModule { }
Original file line number Diff line number Diff line change
1
+ {
2
+ "HELLO" : " hello {{value}}"
3
+ }
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export = (options: Options = {}) => {
105
105
https : true ,
106
106
overlay : true ,
107
107
noInfo : false ,
108
- contentBase : [ buildPath ] ,
108
+ contentBase : [ buildPath , sourcePath ] ,
109
109
port : 8087 ,
110
110
historyApiFallback : true ,
111
111
hot : true ,
You can’t perform that action at this time.
0 commit comments