UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

320 lines 9.08 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 L10nDecimalDirective = /** @class */ (function (_super) { tslib_1.__extends(L10nDecimalDirective, _super); function L10nDecimalDirective(locale, el, renderer) { var _this = _super.call(this, el, renderer) || this; _this.locale = locale; _this.el = el; _this.renderer = renderer; return _this; } Object.defineProperty(L10nDecimalDirective.prototype, "l10nDecimal", { set: /** * @param {?} digits * @return {?} */ function (digits) { this.digits = digits; }, enumerable: true, configurable: true }); /** * @return {?} */ L10nDecimalDirective.prototype.setup = /** * @return {?} */ function () { var _this = this; this.replace(); this.locale.defaultLocaleChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); }; /** * @return {?} */ L10nDecimalDirective.prototype.replace = /** * @return {?} */ function () { this.replaceText(); this.replaceAttributes(); }; /** * @return {?} */ L10nDecimalDirective.prototype.replaceText = /** * @return {?} */ function () { if (!!this.key) { this.setText(this.getValue(this.key)); } }; /** * @return {?} */ L10nDecimalDirective.prototype.replaceAttributes = /** * @return {?} */ function () { if (this.attributes.length > 0) { this.setAttributes(this.getAttributesData()); } }; /** * @param {?} key * @return {?} */ L10nDecimalDirective.prototype.getValue = /** * @param {?} key * @return {?} */ function (key) { return this.locale.formatDecimal(key, this.digits); }; L10nDecimalDirective.decorators = [ { type: Directive, args: [{ selector: '[l10nDecimal]' },] } ]; /** @nocollapse */ L10nDecimalDirective.ctorParameters = function () { return [ { type: LocaleService }, { type: ElementRef }, { type: Renderer2 } ]; }; L10nDecimalDirective.propDecorators = { l10nDecimal: [{ type: Input }], digits: [{ type: Input }] }; return L10nDecimalDirective; }(BaseDirective)); export { L10nDecimalDirective }; if (false) { /** @type {?} */ L10nDecimalDirective.prototype.digits; /** @type {?} */ L10nDecimalDirective.prototype.locale; /** @type {?} */ L10nDecimalDirective.prototype.el; /** @type {?} */ L10nDecimalDirective.prototype.renderer; } var L10nPercentDirective = /** @class */ (function (_super) { tslib_1.__extends(L10nPercentDirective, _super); function L10nPercentDirective(locale, el, renderer) { var _this = _super.call(this, el, renderer) || this; _this.locale = locale; _this.el = el; _this.renderer = renderer; return _this; } Object.defineProperty(L10nPercentDirective.prototype, "l10nPercent", { set: /** * @param {?} digits * @return {?} */ function (digits) { this.digits = digits; }, enumerable: true, configurable: true }); /** * @return {?} */ L10nPercentDirective.prototype.setup = /** * @return {?} */ function () { var _this = this; this.replace(); this.locale.defaultLocaleChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); }; /** * @return {?} */ L10nPercentDirective.prototype.replace = /** * @return {?} */ function () { this.replaceText(); this.replaceAttributes(); }; /** * @return {?} */ L10nPercentDirective.prototype.replaceText = /** * @return {?} */ function () { if (!!this.key) { this.setText(this.getValue(this.key)); } }; /** * @return {?} */ L10nPercentDirective.prototype.replaceAttributes = /** * @return {?} */ function () { if (this.attributes.length > 0) { this.setAttributes(this.getAttributesData()); } }; /** * @param {?} key * @return {?} */ L10nPercentDirective.prototype.getValue = /** * @param {?} key * @return {?} */ function (key) { return this.locale.formatPercent(key, this.digits); }; L10nPercentDirective.decorators = [ { type: Directive, args: [{ selector: '[l10nPercent]' },] } ]; /** @nocollapse */ L10nPercentDirective.ctorParameters = function () { return [ { type: LocaleService }, { type: ElementRef }, { type: Renderer2 } ]; }; L10nPercentDirective.propDecorators = { l10nPercent: [{ type: Input }], digits: [{ type: Input }] }; return L10nPercentDirective; }(BaseDirective)); export { L10nPercentDirective }; if (false) { /** @type {?} */ L10nPercentDirective.prototype.digits; /** @type {?} */ L10nPercentDirective.prototype.locale; /** @type {?} */ L10nPercentDirective.prototype.el; /** @type {?} */ L10nPercentDirective.prototype.renderer; } var L10nCurrencyDirective = /** @class */ (function (_super) { tslib_1.__extends(L10nCurrencyDirective, _super); function L10nCurrencyDirective(locale, el, renderer) { var _this = _super.call(this, el, renderer) || this; _this.locale = locale; _this.el = el; _this.renderer = renderer; return _this; } Object.defineProperty(L10nCurrencyDirective.prototype, "l10nCurrency", { set: /** * @param {?} digits * @return {?} */ function (digits) { this.digits = digits; }, enumerable: true, configurable: true }); /** * @return {?} */ L10nCurrencyDirective.prototype.setup = /** * @return {?} */ function () { var _this = this; this.replace(); this.locale.defaultLocaleChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); this.locale.currencyCodeChanged.pipe(takeUntil(this.destroy)).subscribe(function () { _this.replace(); }); }; /** * @return {?} */ L10nCurrencyDirective.prototype.replace = /** * @return {?} */ function () { this.replaceText(); this.replaceAttributes(); }; /** * @return {?} */ L10nCurrencyDirective.prototype.replaceText = /** * @return {?} */ function () { if (!!this.key) { this.setText(this.getValue(this.key)); } }; /** * @return {?} */ L10nCurrencyDirective.prototype.replaceAttributes = /** * @return {?} */ function () { if (this.attributes.length > 0) { this.setAttributes(this.getAttributesData()); } }; /** * @param {?} key * @return {?} */ L10nCurrencyDirective.prototype.getValue = /** * @param {?} key * @return {?} */ function (key) { return this.locale.formatCurrency(key, this.digits, this.currencyDisplay); }; L10nCurrencyDirective.decorators = [ { type: Directive, args: [{ selector: '[l10nCurrency]' },] } ]; /** @nocollapse */ L10nCurrencyDirective.ctorParameters = function () { return [ { type: LocaleService }, { type: ElementRef }, { type: Renderer2 } ]; }; L10nCurrencyDirective.propDecorators = { l10nCurrency: [{ type: Input }], currencyDisplay: [{ type: Input }], digits: [{ type: Input }] }; return L10nCurrencyDirective; }(BaseDirective)); export { L10nCurrencyDirective }; if (false) { /** @type {?} */ L10nCurrencyDirective.prototype.currencyDisplay; /** @type {?} */ L10nCurrencyDirective.prototype.digits; /** @type {?} */ L10nCurrencyDirective.prototype.locale; /** @type {?} */ L10nCurrencyDirective.prototype.el; /** @type {?} */ L10nCurrencyDirective.prototype.renderer; } //# sourceMappingURL=l10n-number.directive.js.map