Skip to content

Commit 06ce034

Browse files
committed
chore: formatting
1 parent 2ae326e commit 06ce034

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

projects/ngx-translate/src/lib/translate.directive.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import {
88
OnDestroy,
99
} from "@angular/core";
1010
import { isObservable, Subscription } from "rxjs";
11-
import {
12-
TranslateService,
13-
14-
} from "./translate.service";
11+
import { TranslateService } from "./translate.service";
1512
import { equals, isDefinedAndNotNull, isString } from "./util";
1613
import {
1714
FallbackLangChangeEvent,

projects/ngx-translate/src/lib/translate.pipe.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import {
77
PipeTransform,
88
} from "@angular/core";
99
import { isObservable, Subscription } from "rxjs";
10-
import {
11-
TranslateService,
12-
13-
} from "./translate.service";
10+
import { TranslateService } from "./translate.service";
1411
import { equals, isDefinedAndNotNull, isDict, isString } from "./util";
1512
import {
1613
InterpolatableTranslationObject,

projects/ngx-translate/src/lib/translate.service.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
TranslationObject,
2323
} from "./translate.service.interface";
2424

25-
2625
/**
2726
* Configuration object for the translation service.
2827
*
@@ -54,11 +53,10 @@ const makeObservable = <T>(value: T | Observable<T>): Observable<T> => {
5453
return isObservable(value) ? value : of(value);
5554
};
5655

57-
58-
5956
@Injectable()
6057
export class TranslateService implements ITranslateService {
61-
protected loadingTranslations: Record<Language, Observable<InterpolatableTranslationObject>> = {};
58+
protected loadingTranslations: Record<Language, Observable<InterpolatableTranslationObject>> =
59+
{};
6260
protected lastUseLanguage: Language | null = null;
6361

6462
protected currentLoader = inject(TranslateLoader);
@@ -149,8 +147,7 @@ export class TranslateService implements ITranslateService {
149147
return of(this.store.getTranslations(lang));
150148
}
151149

152-
protected isLoading(): boolean
153-
{
150+
protected isLoading(): boolean {
154151
return Object.keys(this.loadingTranslations).length > 0;
155152
}
156153

@@ -188,7 +185,9 @@ export class TranslateService implements ITranslateService {
188185
/**
189186
* Retrieves the given translations
190187
*/
191-
protected loadOrExtendLanguage(lang: Language): Observable<InterpolatableTranslationObject> | undefined {
188+
protected loadOrExtendLanguage(
189+
lang: Language,
190+
): Observable<InterpolatableTranslationObject> | undefined {
192191
// if this language is unavailable or extend is true, ask for it
193192
if (!this.store.hasTranslationFor(lang) || this.extend) {
194193
return this.loadAndCompileTranslations(lang);
@@ -224,15 +223,12 @@ export class TranslateService implements ITranslateService {
224223
protected loadAndCompileTranslations(
225224
lang: Language,
226225
): Observable<InterpolatableTranslationObject> {
227-
228-
if(this.loadingTranslations[lang]) {
226+
if (this.loadingTranslations[lang]) {
229227
return this.loadingTranslations[lang];
230228
}
231229

232230
const translations$ = this.currentLoader.getTranslation(lang).pipe(
233-
map((res: TranslationObject) =>
234-
this.compiler.compileTranslations(res, lang),
235-
),
231+
map((res: TranslationObject) => this.compiler.compileTranslations(res, lang)),
236232
tap((compiled: InterpolatableTranslationObject) => {
237233
this.store.setTranslations(lang, compiled, this.extend);
238234
}),
@@ -474,7 +470,6 @@ export class TranslateService implements ITranslateService {
474470
key: string | string[],
475471
interpolateParams?: InterpolationParameters,
476472
): Translation {
477-
478473
if (!isDefinedAndNotNull(key) || key.length === 0) {
479474
return "";
480475
}
@@ -484,9 +479,7 @@ export class TranslateService implements ITranslateService {
484479
return isObservable(result) ? this.keyToObject(key) : result;
485480
}
486481

487-
488-
protected keyToObject(key: string | string[])
489-
{
482+
protected keyToObject(key: string | string[]) {
490483
if (Array.isArray(key)) {
491484
return key.reduce((acc: Record<string, string>, currKey: string) => {
492485
acc[currKey] = currKey;
@@ -615,5 +608,4 @@ export class TranslateService implements ITranslateService {
615608
get onDefaultLangChange(): Observable<DefaultLangChangeEvent> {
616609
return this.store.onFallbackLangChange;
617610
}
618-
619611
}

projects/ngx-translate/src/tests/translate.providers.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import {
1212
} from "../lib/translate.providers";
1313
import { Observable, of } from "rxjs";
1414

15-
import {
16-
TranslateService,
17-
TRANSLATE_SERVICE_CONFIG,
18-
19-
20-
} from "../lib/translate.service";
15+
import { TranslateService, TRANSLATE_SERVICE_CONFIG } from "../lib/translate.service";
2116
import { TranslateLoader, TranslateNoOpLoader } from "../lib/translate.loader";
2217
import { TranslateCompiler, TranslateNoOpCompiler } from "../lib/translate.compiler";
2318
import {

0 commit comments

Comments
 (0)