Skip to content

Commit 716262c

Browse files
committed
chore: Update ReadMe sample.
1 parent 16b8547 commit 716262c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,35 @@ We assume that you already installed [ngx-translate](https://github.com/ngx-tran
1616
Now you need to install the npm module for `MultiTranslateHttpLoader`:
1717

1818
```sh
19-
npm install @ngx-translate/multi-http-loader --save
19+
npm install ngx-translate-multi-http-loader --save
2020
```
2121

2222
Choose the version corresponding to your Angular version:
2323

2424
Angular | @ngx-translate/core | @ngx-translate/multi-http-loader
2525
----------- | ------------------- | --------------------------
26-
6 | 10.x+ | 3.x+
27-
5 | 8.x to 9.x | 1.x to 2.x
28-
4.3 | 7.x or less | 1.x to 2.x
29-
2 to 4.2.x | 7.x or less | 0.x
26+
6 | 10.x+ | 1.x+
3027

3128
## Usage
3229
#### 1. Setup the `TranslateModule` to use the `MultiTranslateHttpLoader`:
3330

3431
The `MultiTranslateHttpLoader` uses HttpClient to load translations, which means that you have to import the HttpClientModule from `@angular/common/http` before the `TranslateModule`:
3532

33+
3634
```ts
3735
import {NgModule} from '@angular/core';
3836
import {BrowserModule} from '@angular/platform-browser';
3937
import {HttpClientModule, HttpClient} from '@angular/common/http';
4038
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
41-
import {TranslateHttpLoader} from '@ngx-translate/multi-http-loader';
39+
import {MultiTranslateHttpLoader} from "ngx-translate-multi-http-loader";
4240
import {AppComponent} from "./app";
4341

4442
// AoT requires an exported function for factories
4543
export function HttpLoaderFactory(http: HttpClient) {
46-
return new TranslateHttpLoader(http);
44+
return new MultiTranslateHttpLoader(http, [
45+
{prefix: "./assets/translate/core/", suffix: ".json"},
46+
{prefix: "./assets/translate/shared/", suffix: ".json"},
47+
]);
4748
}
4849

4950
@NgModule({
@@ -63,17 +64,20 @@ export function HttpLoaderFactory(http: HttpClient) {
6364
export class AppModule { }
6465
```
6566

66-
The `MultiTranslateHttpLoader` also has two optional parameters:
67+
The `MultiTranslateHttpLoader` takes a list of translation file configurations. Each configuration has two optional parameters:
6768
- prefix: string = "/assets/i18n/"
6869
- suffix: string = ".json"
6970

7071
By using those default parameters, it will load your translations files for the lang "en" from: `/assets/i18n/en.json`.
7172

72-
You can change those in the `HttpLoaderFactory` method that we just defined. For example if you want to load the "en" translations from `/public/lang-files/en-lang.json` you would use:
73+
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:
7374

7475
```ts
7576
export function HttpLoaderFactory(http: HttpClient) {
76-
return new TranslateHttpLoader(http, "/public/lang-files/", "-lang.json");
77+
return new MultiTranslateHttpLoader(http, [
78+
{prefix: "./assets/translate/core/", suffix: ".json"},
79+
{prefix: "./assets/translate/shared/", suffix: ".json"},
80+
]);
7781
}
7882
```
7983

0 commit comments

Comments
 (0)