Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
feat(http-loader): support for Angular 6 and RxJS 6
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The library is now compatible with Angular 6+ and RxJS 6+. If you need to use Angular 5, please stay on version 2.0.1. If you need to use RxJS 5, update to 5.6 and use the rxjs-compat library (see [the RxJS update guide](https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/preview#))
  • Loading branch information
ocombe committed Mar 28, 2018
1 parent 3f59877 commit 813653d
Show file tree
Hide file tree
Showing 15 changed files with 2,665 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ npm-debug.log
coverage
*.metadata.json
bundles
build
dist
dist.tgz

#################
## JetBrains
Expand Down
29 changes: 12 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
language: node_js

cache: yarn

sudo: false

notifications:
email: false

node_js:
- '7'

branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"

- '8'
before_install:
- export CHROME_BIN=chromium-browser

before_script:
- npm prune

- npm i -g npm@3 # fix for https://github.com/npm/npm/issues/19222
after_success:
- npm run semantic-release

- yarn build
- cp .git dist/ -r # required by semantic release
- cp README.md dist/
- cd dist
- yarn install
- yarn semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sh -e /etc/init.d/xvfb start
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Now you need to install the npm module for `TranslateHttpLoader`:
npm install @ngx-translate/http-loader --save
```

**NB: if you're still on Angular <4.3, please use Http from @angular/http with [email protected].**
**if you're still on Angular <4.3, please use Http from @angular/http with [email protected].**

**If you're still using Angular v5, please use ngx-translate 9.x and http-loader 2.x, version 3 and above are only compatible with Angular v6. If you need to use RxJS 5, update to 5.6 and use the rxjs-compat library (see [the RxJS update guide](https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/preview#)).**

## Usage
#### 1. Setup the `TranslateModule` to use the `TranslateHttpLoader`:
Expand Down
4 changes: 2 additions & 2 deletions config/spec-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require('zone.js/dist/proxy'); // since zone.js 0.6.15
require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14

// RxJS
require('rxjs/Rx');
require('rxjs');

var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
Expand Down Expand Up @@ -55,4 +55,4 @@ function requireAll(requireContext) {
}

// requires and returns all modules that match
var modules = requireAll(testContext);
var modules = requireAll(testContext);
8 changes: 4 additions & 4 deletions config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {

resolve: {
extensions: ['.ts', '.js'],
modules: [helpers.root('src'), 'node_modules']
modules: [helpers.root('lib/src'), 'node_modules']
},

module: {
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = {
enforce: 'post',
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
include: helpers.root('src'),
include: helpers.root('lib/src'),
exclude: [/\.spec\.ts$/, /\.e2e\.ts$/, /node_modules/]
}]
},
Expand All @@ -64,7 +64,7 @@ module.exports = {
// fix the warning in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
helpers.root('./src')
helpers.root('lib/src')
),

new LoaderOptionsPlugin({
Expand All @@ -80,7 +80,7 @@ module.exports = {
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
resourcePath: 'lib/src'
}
}
})
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions lib/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"dest": "dist",
"keepLifecycleScripts": true,
"workingDirectory": ".ng_build",
"lib": {
"entryFile": "index.ts"
}
}
32 changes: 32 additions & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@ngx-translate/http-loader",
"description": "A loader for ngx-translate that loads translations using http",
"repository": {
"type": "git",
"url": "git+https://github.com/ngx-translate/http-loader.git"
},
"keywords": [
"angular",
"angular 2",
"i18n",
"translate",
"ngx-translate"
],
"author": "Olivier Combe",
"license": "MIT",
"bugs": {
"url": "https://github.com/ngx-translate/http-loader/issues"
},
"homepage": "https://github.com/ngx-translate/http-loader",
"peerDependencies": {
"@ngx-translate/core": ">=10.0.0",
"@angular/core": ">=6.0.0-rc.0",
"@angular/http": ">=6.0.0-rc.0"
},
"devDependencies": {
"semantic-release": "8.2.3"
},
"scripts": {
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
}
}
13 changes: 13 additions & 0 deletions lib/src/http-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {HttpClient} from "@angular/common/http";
import {TranslateLoader} from "@ngx-translate/core";

export class TranslateHttpLoader implements TranslateLoader {
constructor(private http: HttpClient, public prefix: string = "/assets/i18n/", public suffix: string = ".json") {}

/**
* Gets the translations from the server
*/
public getTranslation(lang: string): any {
return this.http.get(`${this.prefix}${lang}${this.suffix}`);
}
}
82 changes: 42 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "@ngx-translate/http-loader",
"description": "A loader for ngx-translate that loads translations using http",
"scripts": {
"clean": "rimraf bundles coverage src/**/*.d.ts src/**/*.metadata.json src/**/*.js tests/**/*.d.ts tests/**/*.metadata.json tests/**/*.js index.d.ts index.metadata.json index.js",
"prebuild": "npm run clean",
"build": "ng-packagr -p lib/ng-package.json && mv lib/dist ./ && mv lib/dist.tgz ./",
"clean": "rimraf dist dist.tgz bundles coverage src/**/*.d.ts src/**/*.metadata.json src/**/*.js tests/**/*.d.ts tests/**/*.metadata.json tests/**/*.js index.d.ts index.metadata.json index.js",
"commit": "git-cz",
"lint": "npm run clean && tslint --project tsconfig.json lib/src/**/*.ts",
"test": "karma start",
"test-watch": "karma start --singleRun=false --autoWatch=true",
"prepublish": "ngc && npm run build",
"build": "webpack",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"test-watch": "karma start --singleRun=false --autoWatch=true"
},
"repository": {
"type": "git",
Expand All @@ -30,51 +31,52 @@
"module": "index.js",
"typings": "index.d.ts",
"peerDependencies": {
"@ngx-translate/core": ">=6.0.0",
"@angular/core": ">=4.3.0",
"@angular/common": ">=4.3.0"
"@ngx-translate/core": ">=10.0.0",
"@angular/core": ">=6.0.0-rc.0",
"@angular/common": ">=6.0.0-rc.0"
},
"devDependencies": {
"@angular/animations": "4.3.1",
"@angular/common": "4.3.1",
"@angular/compiler": "4.3.1",
"@angular/compiler-cli": "4.3.1",
"@angular/core": "4.3.1",
"@ngx-translate/core": "7.0.0",
"@angular/platform-browser": "4.3.1",
"@angular/platform-browser-dynamic": "4.3.1",
"@angular/platform-server": "4.3.1",
"@types/hammerjs": "2.0.34",
"@types/jasmine": "2.5.51",
"@types/node": "7.0.28",
"awesome-typescript-loader": "3.1.3",
"clean-webpack-plugin": "0.1.16",
"codelyzer": "3.0.1",
"@angular/animations": "6.0.0-rc.0",
"@angular/common": "6.0.0-rc.0",
"@angular/compiler": "6.0.0-rc.0",
"@angular/compiler-cli": "6.0.0-rc.0",
"@angular/core": "6.0.0-rc.0",
"@angular/platform-browser": "6.0.0-rc.0",
"@angular/platform-browser-dynamic": "6.0.0-rc.0",
"@angular/platform-server": "6.0.0-rc.0",
"@ngx-translate/core": "file:../ngx-translate/dist.tgz",
"@types/hammerjs": "2.0.35",
"@types/jasmine": "2.8.2",
"@types/node": "8.0.53",
"awesome-typescript-loader": "3.4.0",
"clean-webpack-plugin": "0.1.19",
"codelyzer": "4.2.1",
"commitizen": "2.9.6",
"core-js": "2.4.1",
"cz-conventional-changelog": "2.0.0",
"istanbul-instrumenter-loader": "2.0.0",
"jasmine-core": "2.6.2",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"core-js": "2.5.4",
"cz-conventional-changelog": "2.1.0",
"istanbul-instrumenter-loader": "3.0.0",
"jasmine-core": "2.8.0",
"karma": "1.7.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.1",
"karma-jasmine": "1.1.0",
"karma-mocha-reporter": "2.2.3",
"karma-mocha-reporter": "2.2.5",
"karma-remap-coverage": "0.1.4",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.3",
"karma-webpack": "2.0.6",
"loader-utils": "1.1.0",
"reflect-metadata": "0.1.10",
"rimraf": "2.6.1",
"rxjs": "5.4.0",
"semantic-release": "6.3.6",
"source-map-loader": "0.2.1",
"ng-packagr": "2.4.1",
"reflect-metadata": "0.1.12",
"rimraf": "2.6.2",
"rxjs": "^6.0.0-beta.3",
"source-map-loader": "0.2.3",
"ts-helpers": "1.1.2",
"tslint": "5.4.3",
"tsickle": "0.27.2",
"tslint": "5.8.0",
"tslint-loader": "3.5.3",
"typescript": "2.3.4",
"webpack": "3.0.0-rc.1",
"zone.js": "0.8.11"
"typescript": "2.7.x",
"webpack": "3.8.1",
"zone.js": "0.8.20"
},
"config": {
"commitizen": {
Expand Down
15 changes: 0 additions & 15 deletions src/http-loader.ts

This file was deleted.

Loading

0 comments on commit 813653d

Please sign in to comment.