UNPKG

@itwin/core-react

Version:

A react component library of iTwin.js UI general purpose components

69 lines 2.86 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Utilities */ /** Import color variables, layout variables and Sass classes barrel file */ import "./colorthemes.scss"; import "./colorvariables.scss"; import "./layout-variables.scss"; import "./classes.scss"; import { Logger } from "@itwin/core-bentley"; /* eslint-disable @typescript-eslint/no-deprecated */ /** Manages the Localization service for the core-react package. * @public * @deprecated in 4.16.0. `@itwin/core-react` package is deprecated, see used modules for suggested replacements. */ export class UiCore { /** * Registers the Localization service namespace for UiCore. * @param localization The internationalization service created by the host application. */ static async initialize(localization) { if (UiCore._initialized) { Logger.logInfo(UiCore.loggerCategory("UiCore"), `UiCore.initialize already called`); return; } UiCore._localization = localization; await UiCore._localization.registerNamespace(UiCore.localizationNamespace); UiCore._initialized = true; } /** Unregisters the UiCore localization namespace */ static terminate() { if (UiCore._localization) UiCore._localization.unregisterNamespace(UiCore.localizationNamespace); UiCore._localization = undefined; UiCore._initialized = false; } /** Determines if UiCore has been initialized */ static get initialized() { return UiCore._initialized; } /** The internationalization service namespace. */ static get localizationNamespace() { return "UiCore"; } /** Calls localization.getLocalizedString with the "UiCore" namespace. Do NOT include the namespace in the key. * @deprecated in 4.12.0. Do not use this internally, this is replaced by `useTranslation`. * @internal */ static translate(key) { if (!UiCore._localization) { Logger.logError(UiCore.loggerCategory("UiCore"), `translate: UiCore must be initialize with a localization provider. Returning blank string.`); return ""; } return UiCore._localization.getLocalizedString(`${UiCore.localizationNamespace}:${String(key)}`); } /** @internal */ static get packageName() { return "core-react"; } /** @internal */ static loggerCategory(name) { return `${UiCore.packageName}.${name}`; } } UiCore._initialized = false; //# sourceMappingURL=UiCore.js.map