diff --git a/README.md b/README.md index d6dbb155..828437b6 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ npm install ng2-translate --save ## Usage -Finally, you can use ng2-translate in your Angular 2 project (make sure that you've loaded the angular2/http bundle as well). +Finally, you can use ng2-translate in your Angular 2 project (make sure that you've loaded the @angular/http bundle as well). It is recommended to use `TRANSLATE_PROVIDERS` in the bootstrap of your application and to never add `TranslateService` to the "providers" property of your components, this way you will keep it as a singleton. `TRANSLATE_PROVIDERS` provides a default configuration for the static translation file loader. If you add `TranslateService` to the "providers" property of a component it will instantiate a new instance of the service that won't be initialized with the language to use or the default language. ```ts -import {HTTP_PROVIDERS} from 'angular2/http'; -import {Component, Injectable, provide} from 'angular2/core'; +import {HTTP_PROVIDERS} from '@angular/http'; +import {Component, Injectable, provide} from '@angular/core'; import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate'; -import {bootstrap} from 'angular2/platform/browser'; +import {bootstrap} from '@angular/platform-browser-dynamic'; bootstrap(AppComponent, [ HTTP_PROVIDERS, @@ -76,7 +76,7 @@ bootstrap(AppComponent, [ For Ionic 2 here is a complete bootstrap with configuration: ```ts -import {provide} from 'angular2/core'; +import {provide} from '@angular/core'; import {TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate'; @App({ diff --git a/karma-test-shim.js b/karma-test-shim.js index 5f3abf5a..2988b8e2 100644 --- a/karma-test-shim.js +++ b/karma-test-shim.js @@ -11,12 +11,19 @@ System.config({ baseURL: '/base/', defaultJSExtensions: true, map: { - 'angular2': 'node_modules/angular2', + '@angular': 'node_modules/@angular', 'rxjs': 'node_modules/rxjs' + }, + packages: { + '@angular/common': { main: 'index.js', defaultExtension: 'js' }, + '@angular/compiler': { main: 'index.js', defaultExtension: 'js' }, + '@angular/core': { main: 'index.js', defaultExtension: 'js' }, + '@angular/http': { main: 'index.js', defaultExtension: 'js' }, + '@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' } } }); -System.import('angular2/src/platform/browser/browser_adapter').then(function(browser_adapter) { +System.import('@angular/platform-browser/src/browser/browser_adapter').then(function(browser_adapter) { browser_adapter.BrowserDomAdapter.makeCurrent(); }).then(function() { return Promise.all( diff --git a/karma.conf.js b/karma.conf.js index 87625dce..822f3f28 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -21,7 +21,7 @@ module.exports = function(config) { 'node_modules/systemjs/dist/system.src.js', 'node_modules/reflect-metadata/Reflect.js', - { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false, served: true }, + { pattern: 'node_modules/@angular/**/*.js', included: false, watched: false, served: true }, { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true }, { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false, served: true }, // PhantomJS2 (and possibly others) might require it @@ -33,7 +33,7 @@ module.exports = function(config) { // list of files to exclude exclude: [ - 'node_modules/angular2/**/*_spec.js' + 'node_modules/@angular/**/*_spec.js' ], preprocessors: { diff --git a/make.js b/make.js index afafc038..208c1ee7 100644 --- a/make.js +++ b/make.js @@ -12,14 +12,14 @@ var config = { }, map: { typescript: './node_modules/typescript/lib/typescript.js', - angular2: path.resolve('node_modules/angular2'), + '@angular': path.resolve('node_modules/@angular'), rxjs: path.resolve('node_modules/rxjs') }, paths: { '*': '*.js' }, meta: { - 'node_modules/angular2/*': { build: false }, + 'node_modules/@angular/*': { build: false }, 'node_modules/rxjs/*': { build: false } }, }; diff --git a/ng2-translate.ts b/ng2-translate.ts index 9448bc26..08243460 100644 --- a/ng2-translate.ts +++ b/ng2-translate.ts @@ -1,5 +1,5 @@ -import {provide} from 'angular2/core'; -import {Http} from 'angular2/http'; +import {provide} from '@angular/core'; +import {Http} from '@angular/http'; import {TranslatePipe} from './src/translate.pipe'; import {TranslateService, TranslateLoader, TranslateStaticLoader} from './src/translate.service'; diff --git a/package.json b/package.json index bd75f4f6..ce5da9c1 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,18 @@ "typings": "./ng2-translate.d.ts", "homepage": "https://github.com/ocombe/ng2-translate", "peerDependencies": { - "angular2": ">= 2.0.0-beta.16" + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1" }, "devDependencies": { - "angular2": "2.0.0-beta.16", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", "commitizen": "~2.5.0", "cz-conventional-changelog": "~1.1.4", "es6-promise": "^3.0.2", @@ -44,7 +52,7 @@ "karma-jasmine": "~0.3.8", "karma-typescript-preprocessor": "0.0.21", "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", + "rxjs": "5.0.0-beta.6", "semantic-release": "~4.3.5", "systemjs": "~0.19.24", "systemjs-builder": "^0.15.13", @@ -55,5 +63,8 @@ }, "czConfig": { "path": "node_modules/cz-conventional-changelog" + }, + "dependencies": { + "@angular/http": "^2.0.0-rc.1" } } diff --git a/src/translate.pipe.ts b/src/translate.pipe.ts index a4ffa4db..78ee9d31 100644 --- a/src/translate.pipe.ts +++ b/src/translate.pipe.ts @@ -1,6 +1,6 @@ -import {PipeTransform, Pipe, Injectable, EventEmitter, OnDestroy, ChangeDetectorRef} from 'angular2/core'; +import {PipeTransform, Pipe, Injectable, EventEmitter, OnDestroy, ChangeDetectorRef} from '@angular/core'; import {TranslateService, LangChangeEvent} from './translate.service'; -import {isPresent, isArray} from "angular2/src/facade/lang"; +import {isPresent, isArray} from "@angular/core/src/facade/lang"; @Injectable() @Pipe({ diff --git a/src/translate.service.ts b/src/translate.service.ts index f5952dd8..688a4c1e 100644 --- a/src/translate.service.ts +++ b/src/translate.service.ts @@ -1,5 +1,5 @@ -import {Injectable, EventEmitter, Optional} from 'angular2/core'; -import {Http, Response} from 'angular2/http'; +import {Injectable, EventEmitter, Optional} from '@angular/core'; +import {Http, Response} from '@angular/http'; import {Observable} from 'rxjs/Observable' import {Observer} from "rxjs/Observer"; import 'rxjs/add/observable/of'; diff --git a/tests/translate.pipe.spec.ts b/tests/translate.pipe.spec.ts index 2b26331f..8eb3fc3e 100644 --- a/tests/translate.pipe.spec.ts +++ b/tests/translate.pipe.spec.ts @@ -1,8 +1,8 @@ import {TranslatePipe} from '../src/translate.pipe'; -import {MockConnection, MockBackend} from "angular2/src/http/backends/mock_backend"; +import {MockConnection, MockBackend} from "@angular/http/testing/mock_backend"; import {TRANSLATE_PROVIDERS, TranslateService} from "./../ng2-translate"; -import {ResponseOptions, Response, XHRBackend, HTTP_PROVIDERS} from "angular2/http"; -import {provide, Injector, ReflectiveInjector, ChangeDetectorRef} from "angular2/core"; +import {ResponseOptions, Response, XHRBackend, HTTP_PROVIDERS} from "@angular/http"; +import {provide, Injector, ReflectiveInjector, ChangeDetectorRef} from "@angular/core"; import {LangChangeEvent} from "../src/translate.service"; class FakeChangeDetectorRef extends ChangeDetectorRef { diff --git a/tests/translate.service.spec.ts b/tests/translate.service.spec.ts index 9c5e0eea..6ea9c81d 100644 --- a/tests/translate.service.spec.ts +++ b/tests/translate.service.spec.ts @@ -1,7 +1,7 @@ -import {it} from "angular2/testing"; -import {provide, Injector, ReflectiveInjector} from "angular2/core"; -import {ResponseOptions, Response, HTTP_PROVIDERS, XHRBackend} from "angular2/http"; -import {MockBackend, MockConnection} from "angular2/http/testing"; +import {it} from "@angular/core/testing"; +import {provide, Injector, ReflectiveInjector} from "@angular/core"; +import {ResponseOptions, Response, HTTP_PROVIDERS, XHRBackend} from "@angular/http"; +import {MockBackend, MockConnection} from "@angular/http/testing"; import { TRANSLATE_PROVIDERS, TranslateService,