@@ -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 ( )
6057export 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}
0 commit comments