forked from frederikschubert/ng2-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng2-translate.ts
41 lines (37 loc) · 1.1 KB
/
ng2-translate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {NgModule, ModuleWithProviders} from "@angular/core";
import {Http, HttpModule} from "@angular/http";
import {TranslatePipe} from "./src/translate.pipe";
import {TranslateService, TranslateLoader, TranslateStaticLoader} from "./src/translate.service";
export * from "./src/translate.pipe";
export * from "./src/translate.service";
export * from "./src/translate.parser";
// for angular-cli
export default {
pipes: [TranslatePipe],
providers: [TranslateService]
};
export function translateLoaderFactory(http: Http) {
return new TranslateStaticLoader(http);
}
@NgModule({
imports: [HttpModule],
declarations: [
TranslatePipe
],
exports: [
HttpModule, // todo remove this when removing the loader from core
TranslatePipe
]
})
export class TranslateModule {
static forRoot(providedLoader: any = {
provide: TranslateLoader,
useFactory: translateLoaderFactory,
deps: [Http]
}): ModuleWithProviders {
return {
ngModule: TranslateModule,
providers: [providedLoader, TranslateService]
};
}
}