UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

113 lines 3.27 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; import { Directive, ElementRef, Input, Renderer2 } from '@angular/core'; import { takeUntil } from 'rxjs/operators'; import { LocaleService } from '../services/locale.service'; import { BaseDirective } from '../models/base-directive'; var L10nDateDirective = /** @class */ (function (_super) { tslib_1.__extends(L10nDateDirective, _super); function L10nDateDirective(locale, el, renderer) { var _this = _super.call(this, el, renderer) || this; _this.locale = locale; _this.el = el; _this.renderer = renderer; return _this; } Object.defineProperty(L10nDateDirective.prototype, "l10nDate", { set: /** * @param {?} format * @return {?} */ function (format) { this.format = format; }, enumerable: true, configurable: true }); /** * @return {?} */ L10nDateDirective.prototype.setup = /** * @return {?} */ function () { var _this = this; this.replace(); this.locale.defaultLocaleChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); this.locale.timezoneChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); }; /** * @return {?} */ L10nDateDirective.prototype.replace = /** * @return {?} */ function () { this.replaceText(); this.replaceAttributes(); }; /** * @return {?} */ L10nDateDirective.prototype.replaceText = /** * @return {?} */ function () { if (!!this.key) { this.setText(this.getValue(this.key)); } }; /** * @return {?} */ L10nDateDirective.prototype.replaceAttributes = /** * @return {?} */ function () { if (this.attributes.length > 0) { this.setAttributes(this.getAttributesData()); } }; /** * @param {?} key * @return {?} */ L10nDateDirective.prototype.getValue = /** * @param {?} key * @return {?} */ function (key) { return this.locale.formatDate(key, this.format); }; L10nDateDirective.decorators = [ { type: Directive, args: [{ selector: '[l10nDate]' },] } ]; /** @nocollapse */ L10nDateDirective.ctorParameters = function () { return [ { type: LocaleService }, { type: ElementRef }, { type: Renderer2 } ]; }; L10nDateDirective.propDecorators = { l10nDate: [{ type: Input }], format: [{ type: Input }] }; return L10nDateDirective; }(BaseDirective)); export { L10nDateDirective }; if (false) { /** @type {?} */ L10nDateDirective.prototype.format; /** @type {?} */ L10nDateDirective.prototype.locale; /** @type {?} */ L10nDateDirective.prototype.el; /** @type {?} */ L10nDateDirective.prototype.renderer; } //# sourceMappingURL=l10n-date.directive.js.map