ngx-translate-multi-http-loader 7.0.4 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2022 Dennis Keil
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,90 @@
1
- # ngx-translate-multi-http-loader
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Running unit tests
6
-
7
- Run `nx test ngx-translate-multi-http-loader` to execute the unit tests.
1
+ # @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)
2
+
3
+ A loader for [ngx-translate](https://github.com/ngx-translate/core) that loads translations using http.
4
+
5
+ Angular 6 example: https://stackblitz.com/edit/ngx-translate-multi-http-loader-sample
6
+
7
+ Angular 13 example: https://github.com/denniske/ngx-translate-multi-http-loader-demo
8
+
9
+ Get the complete changelog here: https://github.com/denniske/ngx-translate-multi-http-loader/releases
10
+
11
+ * [Installation](#installation)
12
+ * [Usage](#usage)
13
+
14
+ ## Installation
15
+
16
+ We assume that you already installed [ngx-translate](https://github.com/ngx-translate/core).
17
+
18
+ Now you need to install the npm module for `MultiTranslateHttpLoader`:
19
+
20
+ ```sh
21
+ npm install ngx-translate-multi-http-loader --save
22
+ ```
23
+
24
+ Choose the version corresponding to your Angular version:
25
+
26
+ Angular | @ngx-translate/core | ngx-translate-multi-http-loader
27
+ ----------- |---------------------| --------------------------
28
+ 14 | 14.x+ | 8.x+
29
+ 13 | 14.x+ | 7.x+
30
+ 6 | 10.x+ | 1.x+
31
+
32
+ ## Usage
33
+ #### 1. Setup the `TranslateModule` to use the `MultiTranslateHttpLoader`:
34
+
35
+ The `MultiTranslateHttpLoader` uses HttpClient to load translations, which means that you have to import the HttpClientModule from `@angular/common/http` before the `TranslateModule`:
36
+
37
+
38
+ ```ts
39
+ import {NgModule} from '@angular/core';
40
+ import {BrowserModule} from '@angular/platform-browser';
41
+ import {HttpClientModule, HttpClient} from '@angular/common/http';
42
+ import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
43
+ import {MultiTranslateHttpLoader} from "ngx-translate-multi-http-loader";
44
+ import {AppComponent} from "./app";
45
+
46
+ // AoT requires an exported function for factories
47
+ export function HttpLoaderFactory(http: HttpClient) {
48
+ return new MultiTranslateHttpLoader(http, [
49
+ {prefix: "./assets/translate/core/", suffix: ".json"},
50
+ {prefix: "./assets/translate/shared/", suffix: ".json"},
51
+ ]);
52
+ }
53
+
54
+ @NgModule({
55
+ imports: [
56
+ BrowserModule,
57
+ HttpClientModule,
58
+ TranslateModule.forRoot({
59
+ loader: {
60
+ provide: TranslateLoader,
61
+ useFactory: HttpLoaderFactory,
62
+ deps: [HttpClient]
63
+ }
64
+ })
65
+ ],
66
+ bootstrap: [AppComponent]
67
+ })
68
+ export class AppModule { }
69
+ ```
70
+
71
+ The `MultiTranslateHttpLoader` takes a list of translation file configurations. Each configuration has two optional parameters:
72
+ - prefix: string = "/assets/translate/"
73
+ - suffix: string = ".json"
74
+
75
+ By using those default parameters, it will load your translations files for the lang "en" from: `/assets/translate/en.json`.
76
+
77
+ 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:
78
+
79
+ ```ts
80
+ export function HttpLoaderFactory(http: HttpClient) {
81
+ return new MultiTranslateHttpLoader(http, [
82
+ {prefix: "./assets/translate/core/", suffix: ".json"},
83
+ {prefix: "./assets/translate/shared/", suffix: ".json"},
84
+ ]);
85
+ }
86
+ ```
87
+
88
+ For now this loader only support the json format.
89
+
90
+ The loader will merge all translation files from the server using [deepmerge](https://github.com/KyleAMathews/deepmerge).
@@ -1,13 +1,13 @@
1
- import { HttpClient } from "@angular/common/http";
2
- import { TranslateLoader } from "@ngx-translate/core";
3
- import { Observable } from "rxjs";
4
- export interface ITranslationResource {
5
- prefix: string;
6
- suffix: string;
7
- }
8
- export declare class MultiTranslateHttpLoader implements TranslateLoader {
9
- private http;
10
- private resources;
11
- constructor(http: HttpClient, resources: ITranslationResource[]);
12
- getTranslation(lang: string): Observable<any>;
13
- }
1
+ import { HttpClient } from "@angular/common/http";
2
+ import { TranslateLoader } from "@ngx-translate/core";
3
+ import { Observable } from "rxjs";
4
+ export interface ITranslationResource {
5
+ prefix: string;
6
+ suffix: string;
7
+ }
8
+ export declare class MultiTranslateHttpLoader implements TranslateLoader {
9
+ private http;
10
+ private resources;
11
+ constructor(http: HttpClient, resources: ITranslationResource[]);
12
+ getTranslation(lang: string): Observable<any>;
13
+ }
@@ -1,30 +1,21 @@
1
- import { of, forkJoin } from 'rxjs';
2
- import { catchError, map } from 'rxjs/operators';
1
+ import { forkJoin, of } from "rxjs";
2
+ import { catchError, map } from "rxjs/operators";
3
+ // @ts-ignore
3
4
  import merge from 'deepmerge';
4
-
5
- class MultiTranslateHttpLoader {
6
- constructor(http, resources) {
7
- this.http = http;
8
- this.resources = resources;
9
- }
10
- getTranslation(lang) {
11
- const requests = this.resources.map(resource => {
12
- const path = resource.prefix + lang + resource.suffix;
13
- return this.http.get(path).pipe(catchError(res => {
14
- console.error("Something went wrong for the following translation file:", path);
15
- console.error(res.message);
16
- return of({});
17
- }));
18
- });
19
- return forkJoin(requests).pipe(map(response => merge.all(response)));
20
- }
5
+ export class MultiTranslateHttpLoader {
6
+ constructor(http, resources) {
7
+ this.http = http;
8
+ this.resources = resources;
9
+ }
10
+ getTranslation(lang) {
11
+ const requests = this.resources.map(resource => {
12
+ const path = resource.prefix + lang + resource.suffix;
13
+ return this.http.get(path).pipe(catchError(res => {
14
+ console.error("Something went wrong for the following translation file:", path);
15
+ console.error(res.message);
16
+ return of({});
17
+ }));
18
+ });
19
+ return forkJoin(requests).pipe(map(response => merge.all(response)));
20
+ }
21
21
  }
22
-
23
- // export * from './lib/ngx-translate-multi-http-loader.module';
24
-
25
- /**
26
- * Generated bundle index. Do not edit.
27
- */
28
-
29
- export { MultiTranslateHttpLoader };
30
- //# sourceMappingURL=ngx-translate-multi-http-loader.mjs.map
package/package.json CHANGED
@@ -1,38 +1,28 @@
1
1
  {
2
2
  "name": "ngx-translate-multi-http-loader",
3
- "version": "7.0.4",
3
+ "version": "8.0.1",
4
4
  "license": "MIT",
5
5
  "maintainers": [
6
6
  "denniske.npm@gmail.com"
7
7
  ],
8
8
  "peerDependencies": {
9
- "@angular/common": "^13.0.0",
10
- "@angular/core": "^13.0.0",
11
- "@ngx-translate/core": ">=14.0.0",
12
- "rxjs": "^7.4.0"
9
+ "@angular/common": "^14.0.0",
10
+ "@angular/core": "^14.0.0"
13
11
  },
14
12
  "dependencies": {
15
- "tslib": "^2.3.0",
16
- "deepmerge": ">=4.2.2"
13
+ "@angular/common": ">=14.0.0",
14
+ "@angular/core": ">=14.0.0",
15
+ "@ngx-translate/core": ">=14.0.0",
16
+ "deepmerge": ">=4.2.2",
17
+ "rxjs": ">=7.4.0",
18
+ "tslib": ">=2.0.0"
17
19
  },
18
- "module": "fesm2015/ngx-translate-multi-http-loader.mjs",
19
- "es2020": "fesm2020/ngx-translate-multi-http-loader.mjs",
20
- "esm2020": "esm2020/ngx-translate-multi-http-loader.mjs",
21
- "fesm2020": "fesm2020/ngx-translate-multi-http-loader.mjs",
22
- "fesm2015": "fesm2015/ngx-translate-multi-http-loader.mjs",
23
- "typings": "ngx-translate-multi-http-loader.d.ts",
24
- "exports": {
25
- "./package.json": {
26
- "default": "./package.json"
27
- },
28
- ".": {
29
- "types": "./ngx-translate-multi-http-loader.d.ts",
30
- "esm2020": "./esm2020/ngx-translate-multi-http-loader.mjs",
31
- "es2020": "./fesm2020/ngx-translate-multi-http-loader.mjs",
32
- "es2015": "./fesm2015/ngx-translate-multi-http-loader.mjs",
33
- "node": "./fesm2015/ngx-translate-multi-http-loader.mjs",
34
- "default": "./fesm2020/ngx-translate-multi-http-loader.mjs"
35
- }
20
+ "devDependencies": {
21
+ "typescript": ">=4.4.3"
36
22
  },
37
- "sideEffects": false
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "files": [
26
+ "/dist"
27
+ ]
38
28
  }
package/esm2020/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- // export * from './lib/ngx-translate-multi-http-loader.module';
2
- export * from './lib/multi-http-loader';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL25neC10cmFuc2xhdGUtbXVsdGktaHR0cC1sb2FkZXIvc3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGdFQUFnRTtBQUNoRSxjQUFjLHlCQUF5QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLy8gZXhwb3J0ICogZnJvbSAnLi9saWIvbmd4LXRyYW5zbGF0ZS1tdWx0aS1odHRwLWxvYWRlci5tb2R1bGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9tdWx0aS1odHRwLWxvYWRlcic7XHJcbiJdfQ==
@@ -1,21 +0,0 @@
1
- import { forkJoin, of } from "rxjs";
2
- import { catchError, map } from "rxjs/operators";
3
- import merge from 'deepmerge';
4
- export class MultiTranslateHttpLoader {
5
- constructor(http, resources) {
6
- this.http = http;
7
- this.resources = resources;
8
- }
9
- getTranslation(lang) {
10
- const requests = this.resources.map(resource => {
11
- const path = resource.prefix + lang + resource.suffix;
12
- return this.http.get(path).pipe(catchError(res => {
13
- console.error("Something went wrong for the following translation file:", path);
14
- console.error(res.message);
15
- return of({});
16
- }));
17
- });
18
- return forkJoin(requests).pipe(map(response => merge.all(response)));
19
- }
20
- }
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXVsdGktaHR0cC1sb2FkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL25neC10cmFuc2xhdGUtbXVsdGktaHR0cC1sb2FkZXIvc3JjL2xpYi9tdWx0aS1odHRwLWxvYWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQWEsUUFBUSxFQUFFLEVBQUUsRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUM5QyxPQUFPLEVBQUMsVUFBVSxFQUFFLEdBQUcsRUFBQyxNQUFNLGdCQUFnQixDQUFDO0FBQy9DLE9BQU8sS0FBSyxNQUFNLFdBQVcsQ0FBQztBQVE5QixNQUFNLE9BQU8sd0JBQXdCO0lBQ25DLFlBQ1UsSUFBZ0IsRUFDaEIsU0FBaUM7UUFEakMsU0FBSSxHQUFKLElBQUksQ0FBWTtRQUNoQixjQUFTLEdBQVQsU0FBUyxDQUF3QjtJQUN4QyxDQUFDO0lBRUcsY0FBYyxDQUFDLElBQVk7UUFDaEMsTUFBTSxRQUFRLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ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
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './index';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LXRyYW5zbGF0ZS1tdWx0aS1odHRwLWxvYWRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYnMvbmd4LXRyYW5zbGF0ZS1tdWx0aS1odHRwLWxvYWRlci9zcmMvbmd4LXRyYW5zbGF0ZS1tdWx0aS1odHRwLWxvYWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
@@ -1,30 +0,0 @@
1
- import { of, forkJoin } from 'rxjs';
2
- import { catchError, map } from 'rxjs/operators';
3
- import merge from 'deepmerge';
4
-
5
- class MultiTranslateHttpLoader {
6
- constructor(http, resources) {
7
- this.http = http;
8
- this.resources = resources;
9
- }
10
- getTranslation(lang) {
11
- const requests = this.resources.map(resource => {
12
- const path = resource.prefix + lang + resource.suffix;
13
- return this.http.get(path).pipe(catchError(res => {
14
- console.error("Something went wrong for the following translation file:", path);
15
- console.error(res.message);
16
- return of({});
17
- }));
18
- });
19
- return forkJoin(requests).pipe(map(response => merge.all(response)));
20
- }
21
- }
22
-
23
- // export * from './lib/ngx-translate-multi-http-loader.module';
24
-
25
- /**
26
- * Generated bundle index. Do not edit.
27
- */
28
-
29
- export { MultiTranslateHttpLoader };
30
- //# sourceMappingURL=ngx-translate-multi-http-loader.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-translate-multi-http-loader.mjs","sources":["../../../../libs/ngx-translate-multi-http-loader/src/lib/multi-http-loader.ts","../../../../libs/ngx-translate-multi-http-loader/src/index.ts","../../../../libs/ngx-translate-multi-http-loader/src/ngx-translate-multi-http-loader.ts"],"sourcesContent":["import {HttpClient} from \"@angular/common/http\";\r\nimport {TranslateLoader} from \"@ngx-translate/core\";\r\nimport {Observable, forkJoin, of} from \"rxjs\";\r\nimport {catchError, map} from \"rxjs/operators\";\r\nimport merge from 'deepmerge';\r\n\r\n\r\nexport interface ITranslationResource {\r\n prefix: string;\r\n suffix: string;\r\n}\r\n\r\nexport class MultiTranslateHttpLoader implements TranslateLoader {\r\n constructor(\r\n private http: HttpClient,\r\n private resources: ITranslationResource[],\r\n ) {}\r\n\r\n public getTranslation(lang: string): Observable<any> {\r\n const requests = this.resources.map(resource => {\r\n const path = resource.prefix + lang + resource.suffix;\r\n return this.http.get(path).pipe(catchError(res => {\r\n console.error(\"Something went wrong for the following translation file:\", path);\r\n console.error(res.message);\r\n return of({});\r\n }));\r\n });\r\n return forkJoin(requests).pipe(map(response => merge.all(response)));\r\n }\r\n}\r\n","// export * from './lib/ngx-translate-multi-http-loader.module';\r\nexport * from './lib/multi-http-loader';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAYa,wBAAwB;IACnC,YACU,IAAgB,EAChB,SAAiC;QADjC,SAAI,GAAJ,IAAI,CAAY;QAChB,cAAS,GAAT,SAAS,CAAwB;KACvC;IAEG,cAAc,CAAC,IAAY;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ;YAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG;gBAC5C,OAAO,CAAC,KAAK,CAAC,0DAA0D,EAAE,IAAI,CAAC,CAAC;gBAChF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC3B,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;aACf,CAAC,CAAC,CAAC;SACL,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;KACtE;;;AC5BH;;ACAA;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-translate-multi-http-loader.mjs","sources":["../../../../libs/ngx-translate-multi-http-loader/src/lib/multi-http-loader.ts","../../../../libs/ngx-translate-multi-http-loader/src/index.ts","../../../../libs/ngx-translate-multi-http-loader/src/ngx-translate-multi-http-loader.ts"],"sourcesContent":["import {HttpClient} from \"@angular/common/http\";\r\nimport {TranslateLoader} from \"@ngx-translate/core\";\r\nimport {Observable, forkJoin, of} from \"rxjs\";\r\nimport {catchError, map} from \"rxjs/operators\";\r\nimport merge from 'deepmerge';\r\n\r\n\r\nexport interface ITranslationResource {\r\n prefix: string;\r\n suffix: string;\r\n}\r\n\r\nexport class MultiTranslateHttpLoader implements TranslateLoader {\r\n constructor(\r\n private http: HttpClient,\r\n private resources: ITranslationResource[],\r\n ) {}\r\n\r\n public getTranslation(lang: string): Observable<any> {\r\n const requests = this.resources.map(resource => {\r\n const path = resource.prefix + lang + resource.suffix;\r\n return this.http.get(path).pipe(catchError(res => {\r\n console.error(\"Something went wrong for the following translation file:\", path);\r\n console.error(res.message);\r\n return of({});\r\n }));\r\n });\r\n return forkJoin(requests).pipe(map(response => merge.all(response)));\r\n }\r\n}\r\n","// export * from './lib/ngx-translate-multi-http-loader.module';\r\nexport * from './lib/multi-http-loader';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAYa,wBAAwB;IACnC,YACU,IAAgB,EAChB,SAAiC;QADjC,SAAI,GAAJ,IAAI,CAAY;QAChB,cAAS,GAAT,SAAS,CAAwB;KACvC;IAEG,cAAc,CAAC,IAAY;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ;YAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;YACtD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG;gBAC5C,OAAO,CAAC,KAAK,CAAC,0DAA0D,EAAE,IAAI,CAAC,CAAC;gBAChF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC3B,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;aACf,CAAC,CAAC,CAAC;SACL,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;KACtE;;;AC5BH;;ACAA;;;;;;"}
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './lib/multi-http-loader';
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="ngx-translate-multi-http-loader" />
5
- export * from './index';