@lxlib/theme
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
82 lines • 5.83 kB
JavaScript
/**
* @fileoverview added by tsickle
* Generated from: src/locale/locale.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { Inject, Injectable, Optional, SkipSelf } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import zhCN from './languages/zh-CN';
import { LXLIB_LOCALE } from './locale.tokens';
export class LxlibLocaleService {
/**
* @param {?} locale
*/
constructor(locale) {
this.change$ = new BehaviorSubject(this._locale);
this.setLocale(locale || zhCN);
}
/**
* @return {?}
*/
get change() {
return this.change$.asObservable();
}
/**
* @param {?} locale
* @return {?}
*/
setLocale(locale) {
if (this._locale && this._locale.abbr === locale.abbr) {
return;
}
this._locale = locale;
this.change$.next(locale);
}
/**
* @return {?}
*/
get locale() {
return this._locale;
}
/**
* @param {?} path
* @return {?}
*/
getData(path) {
return (/** @type {?} */ ((this._locale[path] || {})));
}
}
LxlibLocaleService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
LxlibLocaleService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Inject, args: [LXLIB_LOCALE,] }] }
];
if (false) {
/**
* @type {?}
* @private
*/
LxlibLocaleService.prototype._locale;
/**
* @type {?}
* @private
*/
LxlibLocaleService.prototype.change$;
}
/**
* @param {?} exist
* @param {?} locale
* @return {?}
*/
export function LXLIB_LOCALE_SERVICE_PROVIDER_FACTORY(exist, locale) {
return exist || new LxlibLocaleService(locale);
}
/** @type {?} */
export const LXLIB_LOCALE_SERVICE_PROVIDER = {
provide: LxlibLocaleService,
useFactory: LXLIB_LOCALE_SERVICE_PROVIDER_FACTORY,
deps: [[new Optional(), new SkipSelf(), LxlibLocaleService], LXLIB_LOCALE],
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWxlLnNlcnZpY2UuanMiLCJzb3V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