import { TranslationResolver } from "@rxweb/translate" ; import { Observable } from "rxjs" ; import { Injectable } from "@angular/core" ; @ Injectable ( ) export class TranslateLoaderExtension { constructor ( private translationResolver ) { } getTranslation ( lang ) { let translation = this . getName ( lang ) ; this . translationResolver . addConfig ( translation . translationName ) ; return this . translationResolver . resolve ( translation . translationName , translation . lang ) ; } getName ( lang ) { var splitText = lang . split ( '_' ) ; if ( this . translationResolver . allowedLanguages . indexOf ( splitText [ 0 ] ) !== - 1 || splitText . length == 1 ) lang = "global" ; return splitText . length > 1 ? { lang : splitText [ 1 ] , translationName : splitText [ 0 ] } : { lang : splitText [ 0 ] , translationName : lang } ; } }