UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

89 lines (88 loc) 3.67 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { get, isString } from 'lodash'; import { observable, action, computed } from 'mobx'; import bind from '../utils/bind'; import { visualization_zh } from '../constants/language/zh'; import { visualization_en } from '../constants/language/en'; import Store from '../stores/store'; export var Locale; (function (Locale) { Locale["zhCN"] = "zh-cn"; Locale["enUS"] = "en-us"; })(Locale || (Locale = {})); var LanguageService = /** @class */ (function (_super) { __extends(LanguageService, _super); function LanguageService() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.locale = Locale.zhCN; return _this; } Object.defineProperty(LanguageService.prototype, "package", { get: function () { return this.locale === Locale.enUS ? visualization_en : visualization_zh; }, enumerable: false, configurable: true }); LanguageService.prototype.message = function (path) { if (isString(path)) { var message = get(this.package, path); if (message && isString(message)) { return message; } return path; } return path; }; LanguageService.prototype.setLocale = function (locale) { this.locale = locale; }; __decorate([ observable, __metadata("design:type", String) ], LanguageService.prototype, "locale", void 0); __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], LanguageService.prototype, "package", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", String) ], LanguageService.prototype, "message", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], LanguageService.prototype, "setLocale", null); return LanguageService; }(Store)); export { LanguageService }; var languageService = new LanguageService(); export var formatString = languageService.message; export default languageService;