@anglr/translate-extensions
Version:
Angular module - external translation loader for ngx-translate
43 lines • 2.5 kB
JavaScript
import { __decorate, __metadata } from "tslib";
import { forwardRef, Injectable } from '@angular/core';
import { STRING_LOCALIZATION, TypeProvider } from '@anglr/common';
import { TranslateService } from '@ngx-translate/core';
import { map } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@ngx-translate/core";
/**
* Implementation of StringLocalization, which uses ngxTranslate as localization engine
*/
let NgxTranslateStringLocalizationService = class NgxTranslateStringLocalizationService {
//######################### public properties - implementation of StringLocalization #########################
/**
* Occurs when indication that locale has changed and strings should be obtained again, because they have changed
*/
get textsChange() {
return this._translateSvc.onLangChange.pipe(map(() => { }));
}
//######################### constructors #########################
constructor(_translateSvc) {
this._translateSvc = _translateSvc;
}
//######################### public methods - implementation of StringLocalization #########################
/**
* Gets localized string for specified key, interpolation might be used
* @param key - Key to be localizaed
* @param interpolateParams - Optional object storing interpolation parameters
*/
get(key, interpolateParams) {
return this._translateSvc.instant(key, interpolateParams);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: NgxTranslateStringLocalizationService, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: NgxTranslateStringLocalizationService }); }
};
NgxTranslateStringLocalizationService = __decorate([
TypeProvider({ provide: STRING_LOCALIZATION, useClass: forwardRef(() => NgxTranslateStringLocalizationService) }),
__metadata("design:paramtypes", [TranslateService])
], NgxTranslateStringLocalizationService);
export { NgxTranslateStringLocalizationService };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: NgxTranslateStringLocalizationService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i1.TranslateService }] });
//# sourceMappingURL=ngxTranslateStringLocalization.service.js.map