UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

90 lines 2.62 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. */ export class SearchService { /** * @param {?} configuration * @param {?} translation * @param {?} title * @param {?} meta */ constructor(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 * @return {?} */ updateHead(page) { this.translation.translationChanged().subscribe(() => { this.setTitle(page); if (this.configuration.search.metaTags) { for (const name of this.configuration.search.metaTags) { this.updateTag(name, page); } } }); } /** * @param {?} page * @return {?} */ setTitle(page) { this.title.setTitle(this.translation.translate(page + (this.configuration.translation.composedKeySeparator || '') + 'title')); } /** * @param {?} name * @param {?} page * @return {?} */ updateTag(name, page) { this.meta.updateTag({ name: name, content: this.translation.translate(page + (this.configuration.translation.composedKeySeparator || '') + name) }); } } SearchService.decorators = [ { type: Injectable } ]; /** @nocollapse */ SearchService.ctorParameters = () => [ { type: undefined, decorators: [{ type: Inject, args: [L10N_CONFIG,] }] }, { type: TranslationService }, { type: Title }, { type: Meta } ]; if (false) { /** @type {?} */ SearchService.prototype.configuration; /** @type {?} */ SearchService.prototype.translation; /** @type {?} */ SearchService.prototype.title; /** @type {?} */ SearchService.prototype.meta; } //# sourceMappingURL=search.service.js.map