Skip to content

Commit be6ed96

Browse files
Merge pull request #14 from robmanganelly/release-2.0.0
Release 2.0.0
2 parents 34fceb1 + 93a3055 commit be6ed96

File tree

7 files changed

+360
-190
lines changed

7 files changed

+360
-190
lines changed

bun.lock

Lines changed: 313 additions & 143 deletions
Large diffs are not rendered by default.

docs/api.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ type TranslationSource = string;
3232
declare const withTranslationSource: (source?: string | TranslationSourceLocator) => TranslationSource;
3333
```
3434

35-
## useFetchMultiLoader and useHttpMultiLoader
35+
## provideFetchMultiLoader and provideHttpMultiLoader
3636

3737
````typescript
3838
/**
3939
* Use when providing {@link TranslateService }. Add any sources for translations
4040
*
4141
* It uses fetch API
4242
* Use only with client-side rendered applications,
43-
* if your app is rendered by the server prefer {@link useHttpMultiLoader }
43+
* if your app is rendered by the server prefer {@link provideHttpMultiLoader }
4444
*
4545
* Example
4646
* ```typescript
4747
* provideTranslateService({
4848
* //...other properties
49-
* loader: useFetchMultiLoader(
49+
* loader: provideFetchMultiLoader(
5050
* // do not include the host application source, this one is included by default
5151
* withTranslationSource({ locator: 'my-lib-name' }),
5252
* withTranslationSource({ locator: 'another-lib-name' }),
@@ -58,19 +58,19 @@ declare const withTranslationSource: (source?: string | TranslationSourceLocator
5858
* @param features
5959
* @returns
6060
*/
61-
declare const useFetchMultiLoader: (...features: TranslationSource[]) => FactoryProvider;
61+
declare const provideFetchMultiLoader: (...features: TranslationSource[]) => FactoryProvider;
6262
/**
6363
* Use when providing {@link TranslateService }. Add any sources for translations
6464
*
6565
* It uses httpBackend
66-
* If you prefer using fetch API use {@link useFetchMultiLoader }
66+
* If you prefer using fetch API use {@link provideFetchMultiLoader }
6767
*
6868
* Example
6969
* ```typescript
7070
* provideTranslateService({
7171
* //...other properties
7272
* provideHttpClient(),
73-
* loader: useHttpMultiLoader(
73+
* loader: provideHttpMultiLoader(
7474
* // do not include the host application source, this one is included by default
7575
* withTranslationSource({ locator: 'my-lib-name' }),
7676
* withTranslationSource({ locator: 'another-lib-name' }),
@@ -82,7 +82,7 @@ declare const useFetchMultiLoader: (...features: TranslationSource[]) => Factory
8282
* @param features
8383
* @returns
8484
*/
85-
declare const useHttpMultiLoader: (...features: TranslationSource[]) => FactoryProvider;
85+
declare const provideHttpMultiLoader: (...features: TranslationSource[]) => FactoryProvider;
8686
````
8787

8888
## tagFactory

docs/usage.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ We also assume that you are using the standalone API for your angular applicatio
1717

1818
In your `app.config.ts`, at the time of providing `TranslateService` you will pass to the `loader` attribute one of the functions exported by the toolkit:
1919

20-
- `useHttpMultiLoader` It is recommended for most applications, as it uses Angular's `HttpBackend` to load translation files. It requires that you provide `HttpClient` before calling `provideTranslateService`.
20+
- `provideHttpMultiLoader` It is recommended for most applications, as it uses Angular's `HttpBackend` to load translation files. It requires that you provide `HttpClient` before calling `provideTranslateService`.
2121

22-
- `useFetchMultiLoader` It is recommended for client side rendered applications, as it uses the Fetch API to load translation files. This option **cannot** be used in server-side rendered applications (SSR) or Angular Universal, as it relies on browser APIs, but it is better if you are not planning to use SSR or Angular's `HttpClient` at all.
22+
- `provideFetchMultiLoader` It is recommended for client side rendered applications, as it uses the Fetch API to load translation files. This option **cannot** be used in server-side rendered applications (SSR) or Angular Universal, as it relies on browser APIs, but it is better if you are not planning to use SSR or Angular's `HttpClient` at all.
2323

24-
#### Example Configuration with useHttpMultiLoader
24+
#### Example Configuration with provideHttpMultiLoader
2525

2626
```typescript
2727
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from "@angular/core";
2828
import { provideRouter } from "@angular/router";
2929

3030
import { routes } from "./app.routes";
3131
import { provideTranslateService } from "@ngx-translate/core";
32-
import { pathFactory, useHttpMultiLoader } from "@robmanganelly/ngx-translate-toolkit";
32+
import { pathFactory, provideHttpMultiLoader } from "@robmanganelly/ngx-translate-toolkit";
3333
import { provideHttpClient } from "@angular/common/http";
3434

3535
export const translationPaths = pathFactory("testApp");
@@ -40,23 +40,23 @@ export const appConfig: ApplicationConfig = {
4040
provideZoneChangeDetection({ eventCoalescing: true }),
4141
provideHttpClient(),
4242
provideTranslateService({
43-
defaultLanguage: "en-us",
44-
loader: useHttpMultiLoader(),
43+
fallbackLang: "en-us",
44+
loader: provideHttpMultiLoader(),
4545
}),
4646
provideRouter(routes),
4747
],
4848
};
4949
```
5050

51-
#### Example Configuration with useFetchMultiLoader
51+
#### Example Configuration with provideFetchMultiLoader
5252

5353
```typescript
5454
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from "@angular/core";
5555
import { provideRouter } from "@angular/router";
5656

5757
import { routes } from "./app.routes";
5858
import { provideTranslateService } from "@ngx-translate/core";
59-
import { pathFactory, useFetchMultiLoader } from "@robmanganelly/ngx-translate-toolkit";
59+
import { pathFactory, provideFetchMultiLoader } from "@robmanganelly/ngx-translate-toolkit";
6060

6161
export const translationPaths = pathFactory("testApp");
6262

@@ -65,8 +65,8 @@ export const appConfig: ApplicationConfig = {
6565
provideBrowserGlobalErrorListeners(),
6666
provideZoneChangeDetection({ eventCoalescing: true }),
6767
provideTranslateService({
68-
defaultLanguage: "en-us",
69-
loader: useFetchMultiLoader(),
68+
fallbackLang: "en-us",
69+
loader: provideFetchMultiLoader(),
7070
}),
7171
provideRouter(routes),
7272
],
@@ -89,7 +89,7 @@ import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChang
8989
import { provideRouter } from "@angular/router";
9090
import { routes } from "./app.routes";
9191
import { provideTranslateService } from "@ngx-translate/core";
92-
import { pathFactory, useHttpMultiLoader, withTranslationSource, languageSourcePlaceholder } from "@robmanganelly/ngx-translate-toolkit";
92+
import { pathFactory, provideHttpMultiLoader, withTranslationSource, languageSourcePlaceholder } from "@robmanganelly/ngx-translate-toolkit";
9393
import { provideHttpClient } from "@angular/common/http";
9494

9595
export const translationPaths = pathFactory("testApp");
@@ -100,8 +100,8 @@ export const appConfig: ApplicationConfig = {
100100
provideZoneChangeDetection({ eventCoalescing: true }),
101101
provideHttpClient(),
102102
provideTranslateService({
103-
defaultLanguage: "en-us",
104-
loader: useHttpMultiLoader(
103+
fallbackLang: "en-us",
104+
loader: provideHttpMultiLoader(
105105
withTranslationSource({ locator: "cart" }),
106106
withTranslationSource({ locator: "checkout" }),
107107
withTranslationSource({ locator: "product-details" }),

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@
1010
},
1111
"private": true,
1212
"dependencies": {
13-
"@angular/common": "^20.0.0",
14-
"@angular/compiler": "^20.0.0",
15-
"@angular/core": "^20.0.0",
16-
"@angular/forms": "^20.0.0",
17-
"@angular/platform-browser": "^20.0.0",
18-
"@angular/router": "^20.0.0",
19-
"@ngx-translate/core": "^16.0.4",
20-
"rxjs": "~7.8.0",
21-
"tslib": "^2.3.0"
13+
"@angular/common": "^20.1.4",
14+
"@angular/compiler": "^20.1.4",
15+
"@angular/core": "^20.1.4",
16+
"@angular/forms": "^20.1.4",
17+
"@angular/platform-browser": "^20.1.4",
18+
"@angular/router": "^20.1.4",
19+
"@ngx-translate/core": "^17.0.0",
20+
"rxjs": "~7.8.2",
21+
"tslib": "^2.8.1"
2222
},
2323
"devDependencies": {
24-
"@angular/build": "^20.0.1",
25-
"@angular/cli": "^20.0.1",
26-
"@angular/compiler-cli": "^20.0.0",
27-
"@types/jasmine": "~5.1.0",
24+
"@angular/build": "^20.1.4",
25+
"@angular/cli": "^20.1.4",
26+
"@angular/compiler-cli": "^20.1.4",
27+
"@types/jasmine": "~5.1.8",
2828
"@vitest/coverage-v8": "3.2.2",
29-
"jasmine-core": "~5.7.0",
29+
"jasmine-core": "~5.7.1",
3030
"jsdom": "^26.1.0",
31-
"karma": "~6.4.0",
31+
"karma": "~6.4.4",
3232
"karma-chrome-launcher": "~3.2.0",
33-
"karma-coverage": "~2.2.0",
33+
"karma-coverage": "~2.2.1",
3434
"karma-jasmine": "~5.1.0",
3535
"karma-jasmine-html-reporter": "~2.1.0",
36-
"ng-packagr": "^20.0.0",
37-
"typescript": "~5.8.2",
38-
"vitest": "^3.2.2"
36+
"ng-packagr": "^20.1.0",
37+
"typescript": "~5.8.3",
38+
"vitest": "^3.2.4"
3939
}
4040
}

projects/ngx-translate-toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"peerDependencies": {
55
"@angular/common": "^20.0.0",
66
"@angular/core": "^20.0.0",
7-
"@ngx-translate/core": "^15.0.0 || ^16.0.0"
7+
"@ngx-translate/core": "^17.0.0"
88
},
99
"dependencies": {
1010
"tslib": "^2.3.0"

projects/ngx-translate-toolkit/src/lib/multi-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class MultiLoader implements TranslateLoader {
3838
.map((req) =>
3939
(this.a as HttpBackend).handle(req).pipe(
4040
filter((e): e is HttpResponse<unknown> => e instanceof HttpResponse),
41-
map((r) => r.body ?? ({} as TranslationObject)),
41+
map((r) => (r.body ?? {}) as TranslationObject),
4242
catchError(() => of({} as TranslationObject))
4343
)
4444
);

projects/ngx-translate-toolkit/src/lib/provide-loader.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { HttpBackend } from '@angular/common/http';
99
*
1010
* It uses fetch API
1111
* Use only with client-side rendered applications,
12-
* if your app is rendered by the server prefer {@link useHttpMultiLoader }
12+
* if your app is rendered by the server prefer {@link provideHttpMultiLoader }
1313
*
1414
* Example
1515
* ```typescript
1616
* provideTranslateService({
1717
* //...other properties
18-
* loader: useFetchMultiLoader(
18+
* loader: provideFetchMultiLoader(
1919
* // do not include the host application source, this one is included by default
2020
* withTranslationSource({ locator: 'my-lib-name' }),
2121
* withTranslationSource({ locator: 'another-lib-name' }),
@@ -27,7 +27,7 @@ import { HttpBackend } from '@angular/common/http';
2727
* @param features
2828
* @returns
2929
*/
30-
export const useFetchMultiLoader = (
30+
export const provideFetchMultiLoader = (
3131
...features: TranslationSource[]
3232
): FactoryProvider => ({
3333
provide: TranslateLoader,
@@ -40,14 +40,14 @@ export const useFetchMultiLoader = (
4040
* Use when providing {@link TranslateService }. Add any sources for translations
4141
*
4242
* It uses httpBackend
43-
* If you prefer using fetch API use {@link useFetchMultiLoader }
43+
* If you prefer using fetch API use {@link provideFetchMultiLoader }
4444
*
4545
* Example
4646
* ```typescript
4747
* provideTranslateService({
4848
* //...other properties
4949
* provideHttpClient(),
50-
* loader: useHttpMultiLoader(
50+
* loader: provideHttpMultiLoader(
5151
* // do not include the host application source, this one is included by default
5252
* withTranslationSource({ locator: 'my-lib-name' }),
5353
* withTranslationSource({ locator: 'another-lib-name' }),
@@ -59,7 +59,7 @@ export const useFetchMultiLoader = (
5959
* @param features
6060
* @returns
6161
*/
62-
export const useHttpMultiLoader = (
62+
export const provideHttpMultiLoader = (
6363
...features: TranslationSource[]
6464
): FactoryProvider => ({
6565
provide: TranslateLoader,

0 commit comments

Comments
 (0)