UNPKG

@itwin/presentation-frontend

Version:

Frontend of iModel.js Presentation library

33 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FrontendLocalizationHelper = void 0; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const internal_1 = require("@itwin/presentation-common/internal"); const Presentation_js_1 = require("./Presentation.js"); const NAMESPACES = ["Presentation"]; /** @internal */ class FrontendLocalizationHelper extends internal_1.LocalizationHelper { _lang; constructor(lang) { super({ getLocalizedString: (key) => Presentation_js_1.Presentation.localization.getLocalizedString(key, { defaultValue: key, lng: this._lang }) }); this._lang = lang; } get locale() { return this._lang; } set locale(locale) { this._lang = locale; } static async registerNamespaces() { const localizationPromises = NAMESPACES.map(async (namespace) => Presentation_js_1.Presentation.localization.registerNamespace(namespace)); await Promise.all(localizationPromises); } static unregisterNamespaces() { NAMESPACES.map((namespace) => Presentation_js_1.Presentation.localization.unregisterNamespace(namespace)); } } exports.FrontendLocalizationHelper = FrontendLocalizationHelper; //# sourceMappingURL=LocalizationHelper.js.map