Skip to content

Commit

Permalink
fix(npm): Updated to RC 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nsanitate committed May 9, 2016
1 parent 38ec3f1 commit f8dc4a0
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 27 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
11 changes: 9 additions & 2 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
},
};
Expand Down
4 changes: 2 additions & 2 deletions ng2-translate.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -55,5 +63,8 @@
},
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
},
"dependencies": {
"@angular/http": "^2.0.0-rc.1"
}
}
4 changes: 2 additions & 2 deletions src/translate.pipe.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/translate.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions tests/translate.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions tests/translate.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit f8dc4a0

Please sign in to comment.