UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

106 lines 3.3 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import { Injectable, Inject } from "@angular/core"; import { Title, Meta } from "@angular/platform-browser"; import { TranslationService } from "./translation.service"; import { L10N_CONFIG } from "../models/l10n-config"; /** * @record */ export function ISearchService() { } if (false) { /** * @param {?} page * @return {?} */ ISearchService.prototype.updateHead = function (page) { }; } /** * Manages the translation of page 'title' and meta tags. */ var SearchService = /** @class */ (function () { function SearchService(configuration, translation, title, meta) { this.configuration = configuration; this.translation = translation; this.title = title; this.meta = meta; } /** * Translates the 'title' of the page and the provided meta tags. * @param page The key path of the page */ /** * Translates the 'title' of the page and the provided meta tags. * @param {?} page The key path of the page * @return {?} */ SearchService.prototype.updateHead = /** * Translates the 'title' of the page and the provided meta tags. * @param {?} page The key path of the page * @return {?} */ function (page) { var _this = this; this.translation.translationChanged().subscribe(function () { _this.setTitle(page); if (_this.configuration.search.metaTags) { for (var _i = 0, _a = _this.configuration.search.metaTags; _i < _a.length; _i++) { var name_1 = _a[_i]; _this.updateTag(name_1, page); } } }); }; /** * @param {?} page * @return {?} */ SearchService.prototype.setTitle = /** * @param {?} page * @return {?} */ function (page) { this.title.setTitle(this.translation.translate(page + (this.configuration.translation.composedKeySeparator || '') + 'title')); }; /** * @param {?} name * @param {?} page * @return {?} */ SearchService.prototype.updateTag = /** * @param {?} name * @param {?} page * @return {?} */ function (name, page) { this.meta.updateTag({ name: name, content: this.translation.translate(page + (this.configuration.translation.composedKeySeparator || '') + name) }); }; SearchService.decorators = [ { type: Injectable } ]; /** @nocollapse */ SearchService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: Inject, args: [L10N_CONFIG,] }] }, { type: TranslationService }, { type: Title }, { type: Meta } ]; }; return SearchService; }()); export { SearchService }; if (false) { /** @type {?} */ SearchService.prototype.configuration; /** @type {?} */ SearchService.prototype.translation; /** @type {?} */ SearchService.prototype.title; /** @type {?} */ SearchService.prototype.meta; } //# sourceMappingURL=search.service.js.map