UNPKG

@itwin/presentation-frontend

Version:

Frontend of iModel.js Presentation library

29 lines 1.32 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { LocalizationHelper } from "@itwin/presentation-common/internal"; import { Presentation } from "./Presentation.js"; const NAMESPACES = ["Presentation"]; /** @internal */ export class FrontendLocalizationHelper extends LocalizationHelper { _lang; constructor(lang) { super({ getLocalizedString: (key) => 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.localization.registerNamespace(namespace)); await Promise.all(localizationPromises); } static unregisterNamespaces() { NAMESPACES.map((namespace) => Presentation.localization.unregisterNamespace(namespace)); } } //# sourceMappingURL=LocalizationHelper.js.map