ngx-translate-multi-http-loader
Advanced tools
Comparing version 8.0.2 to 9.0.0
{ | ||
"name": "ngx-translate-multi-http-loader", | ||
"version": "8.0.2", | ||
"version": "9.0.0", | ||
"license": "MIT", | ||
"author": "Raphael Balet", | ||
"maintainers": [ | ||
"denniske.npm@gmail.com" | ||
"raphael.balet@outlook.com" | ||
], | ||
"peerDependencies": { | ||
"@angular/common": "^14.0.0", | ||
"@angular/core": "^14.0.0" | ||
"keywords": [ | ||
"angular", | ||
"i18n", | ||
"transalte", | ||
"ngx-translate" | ||
], | ||
"homepage": "https://github.com/rbalet/ngx-translate-multi-http-loader#readme", | ||
"bugs": { | ||
"url": "https://github.com/rbalet/ngx-translate-multi-http-loader/issues" | ||
}, | ||
"repository": { | ||
"url": "https://github.com/rbalet/ngx-translate-multi-http-loader" | ||
}, | ||
"dependencies": { | ||
"@angular/common": ">=14.0.0", | ||
"@angular/core": ">=14.0.0", | ||
"tslib": "^2.4.0" | ||
}, | ||
"peerDependencies": { | ||
"@angular/common": ">=12.0.0", | ||
"@angular/core": ">=12.0.0", | ||
"@ngx-translate/core": ">=14.0.0", | ||
"deepmerge": ">=4.2.2", | ||
"rxjs": ">=7.4.0", | ||
"tslib": ">=2.0.0" | ||
"rxjs": "7.5.7" | ||
}, | ||
"devDependencies": { | ||
"typescript": ">=4.4.3" | ||
"module": "fesm2015/ngx-translate-multi-http-loader.mjs", | ||
"es2020": "fesm2020/ngx-translate-multi-http-loader.mjs", | ||
"esm2020": "esm2020/ngx-translate-multi-http-loader.mjs", | ||
"fesm2020": "fesm2020/ngx-translate-multi-http-loader.mjs", | ||
"fesm2015": "fesm2015/ngx-translate-multi-http-loader.mjs", | ||
"typings": "index.d.ts", | ||
"exports": { | ||
"./package.json": { | ||
"default": "./package.json" | ||
}, | ||
".": { | ||
"types": "./index.d.ts", | ||
"esm2020": "./esm2020/ngx-translate-multi-http-loader.mjs", | ||
"es2020": "./fesm2020/ngx-translate-multi-http-loader.mjs", | ||
"es2015": "./fesm2015/ngx-translate-multi-http-loader.mjs", | ||
"node": "./fesm2015/ngx-translate-multi-http-loader.mjs", | ||
"default": "./fesm2020/ngx-translate-multi-http-loader.mjs" | ||
} | ||
}, | ||
"main": "dist/multi-http-loader.js", | ||
"types": "dist/multi-http-loader.d.ts", | ||
"files": [ | ||
"/dist" | ||
] | ||
} | ||
"sideEffects": false | ||
} |
# @ngx-translate/multi-http-loader [![npm version](https://badge.fury.io/js/ngx-translate-multi-http-loader.svg)](https://badge.fury.io/js/ngx-translate-multi-http-loader) | ||
A loader for [ngx-translate](https://github.com/ngx-translate/core) that loads translations using http. | ||
Angular 13 example: https://github.com/denniske/ngx-translate-multi-http-loader-demo | ||
Angular 6 example: https://stackblitz.com/edit/ngx-translate-multi-http-loader-sample | ||
Angular 13 example: https://github.com/denniske/ngx-translate-multi-http-loader-demo | ||
Get the complete changelog here: https://github.com/denniske/ngx-translate-multi-http-loader/releases | ||
@@ -14,2 +15,6 @@ | ||
## breaking change: v9.0.0 | ||
* This library is now using `httpBackend` instead of the `httpClient`, to avoid being delayed by interceptor, which was creating errors while loading. | ||
* From the v9, the library will only be using a list of `string[]` so `prefix` & `suffix` aren't needed anymore and `.json` gonna be the default suffix. | ||
## Installation | ||
@@ -27,28 +32,25 @@ | ||
Angular | @ngx-translate/core | ngx-translate-multi-http-loader | ||
----------- |---------------------| -------------------------- | ||
14 | 14.x+ | 8.x+ | ||
13 | 14.x+ | 7.x+ | ||
6 | 10.x+ | 1.x+ | ||
| Angular | @ngx-translate/core | ngx-translate-multi-http-loader | | ||
| ------- | ------------------- | ------------------------------- | | ||
| 14 | 14.x+ | 8.x+ | | ||
| 13 | 14.x+ | 7.x+ | | ||
| 6 | 10.x+ | 1.x+ | | ||
## Usage | ||
#### 1. Setup the `TranslateModule` to use the `MultiTranslateHttpLoader`: | ||
_The `MultiTranslateHttpLoader` uses HttpBackend to load translations, therefore :_ | ||
1. Create and export a new `HttpLoaderFactory` function | ||
2. Import the `HttpClientModule` from `@angular/common/http` | ||
3. Setup the `TranslateModule` to use the `MultiTranslateHttpLoader` | ||
The `MultiTranslateHttpLoader` uses HttpClient to load translations, which means that you have to import the HttpClientModule from `@angular/common/http` before the `TranslateModule`: | ||
```ts | ||
```typescript | ||
import {NgModule} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {HttpClientModule, HttpClient} from '@angular/common/http'; | ||
import {HttpClientModule, HttpBackend} from '@angular/common/http'; | ||
import {TranslateModule, TranslateLoader} from '@ngx-translate/core'; | ||
import {MultiTranslateHttpLoader} from "ngx-translate-multi-http-loader"; | ||
import {AppComponent} from "./app"; | ||
import {MultiTranslateHttpLoader} from 'ngx-translate-multi-http-loader'; | ||
import {AppComponent} from './app'; | ||
// AoT requires an exported function for factories | ||
export function HttpLoaderFactory(http: HttpClient) { | ||
return new MultiTranslateHttpLoader(http, [ | ||
{prefix: "./assets/translate/core/", suffix: ".json"}, | ||
{prefix: "./assets/translate/shared/", suffix: ".json"}, | ||
]); | ||
export function HttpLoaderFactory(_httpBackend: HttpBackend) { | ||
return new MultiTranslateHttpLoader(_httpBackend, ['/assets/i18n/core/', '/assets/i18n/vendors/']); | ||
} | ||
@@ -64,3 +66,3 @@ | ||
useFactory: HttpLoaderFactory, | ||
deps: [HttpClient] | ||
deps: [HttpBackend] | ||
} | ||
@@ -74,21 +76,11 @@ }) | ||
The `MultiTranslateHttpLoader` takes a list of translation file configurations. Each configuration has two optional parameters: | ||
- prefix: string = "/assets/translate/" | ||
- suffix: string = ".json" | ||
The `MultiTranslateHttpLoader` takes a list of strings. | ||
By using those default parameters, it will load your translations files for the lang "en" from: `/assets/translate/en.json`. | ||
Those strings, for example `['/assets/i18n/core/', '/assets/i18n/vendors/']`, | ||
will load your translations files for the lang "en" from : `/assets/i18n/core/en.json` and `/assets/i18n/vendors/en.json` | ||
You can change those in the `HttpLoaderFactory` method that we just defined. For example if you want to load the "en" translations from `/assets/translate/core/en.json` and `/assets/translate/shared/en.json` you would use: | ||
```ts | ||
export function HttpLoaderFactory(http: HttpClient) { | ||
return new MultiTranslateHttpLoader(http, [ | ||
{prefix: "./assets/translate/core/", suffix: ".json"}, | ||
{prefix: "./assets/translate/shared/", suffix: ".json"}, | ||
]); | ||
} | ||
``` | ||
The loader will merge all translation files from the server using [deepmerge](https://github.com/KyleAMathews/deepmerge). | ||
For now this loader only support the json format. | ||
The loader will merge all translation files from the server using [deepmerge](https://github.com/KyleAMathews/deepmerge). | ||
## Authors and acknowledgment | ||
* Former maintainer [Dennis Keil](https://github.com/denniske) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
16439
6
0
12
93
0
0
83
1
+ Addedrxjs@7.5.7(transitive)
- Removed@angular/common@>=14.0.0
- Removed@angular/core@>=14.0.0
- Removed@ngx-translate/core@>=14.0.0
- Removeddeepmerge@>=4.2.2
- Removedrxjs@>=7.4.0
- Removedrxjs@7.8.1(transitive)
Updatedtslib@^2.4.0