UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

115 lines 3.34 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 L10nTimeAgoDirective = /** @class */ (function (_super) { tslib_1.__extends(L10nTimeAgoDirective, _super); function L10nTimeAgoDirective(locale, el, renderer) { var _this = _super.call(this, el, renderer) || this; _this.locale = locale; _this.el = el; _this.renderer = renderer; return _this; } Object.defineProperty(L10nTimeAgoDirective.prototype, "l10nTimeAgo", { set: /** * @param {?} format * @return {?} */ function (format) { this.format = format; }, enumerable: true, configurable: true }); /** * @return {?} */ L10nTimeAgoDirective.prototype.setup = /** * @return {?} */ function () { var _this = this; this.replace(); this.locale.defaultLocaleChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); }; /** * @return {?} */ L10nTimeAgoDirective.prototype.replace = /** * @return {?} */ function () { this.replaceText(); this.replaceAttributes(); }; /** * @return {?} */ L10nTimeAgoDirective.prototype.replaceText = /** * @return {?} */ function () { if (!!this.key) { this.setText(this.getValue(this.key)); } }; /** * @return {?} */ L10nTimeAgoDirective.prototype.replaceAttributes = /** * @return {?} */ function () { if (this.attributes.length > 0) { this.setAttributes(this.getAttributesData()); } }; /** * @param {?} key * @return {?} */ L10nTimeAgoDirective.prototype.getValue = /** * @param {?} key * @return {?} */ function (key) { return this.locale.formatRelativeTime(key, this.unit, this.format); }; L10nTimeAgoDirective.decorators = [ { type: Directive, args: [{ selector: '[l10nTimeAgo]' },] } ]; /** @nocollapse */ L10nTimeAgoDirective.ctorParameters = function () { return [ { type: LocaleService }, { type: ElementRef }, { type: Renderer2 } ]; }; L10nTimeAgoDirective.propDecorators = { l10nTimeAgo: [{ type: Input }], unit: [{ type: Input }], format: [{ type: Input }] }; return L10nTimeAgoDirective; }(BaseDirective)); export { L10nTimeAgoDirective }; if (false) { /** @type {?} */ L10nTimeAgoDirective.prototype.unit; /** @type {?} */ L10nTimeAgoDirective.prototype.format; /** @type {?} */ L10nTimeAgoDirective.prototype.locale; /** @type {?} */ L10nTimeAgoDirective.prototype.el; /** @type {?} */ L10nTimeAgoDirective.prototype.renderer; } //# sourceMappingURL=l10n-time-ago.directive.js.map