packageDocumentation module import { enablePatches } from "immer" ; import { Logger } from "@itwin/core-bentley" ; import { IModelApp } from "@itwin/core-frontend" ; import { getClassName } from "@itwin/appui-abstract" ; import { UiComponents } from "@itwin/components-react" ; import { EmptyLocalization } from "@itwin/core-common" ; public export class UiIModelComponents { private static _initialized = false ; /**
     * initialize UiIModelComponents.
     */ public static async initialize ( ) { if ( UiIModelComponents . _initialized ) { Logger . logInfo ( UiIModelComponents . loggerCategory ( UiIModelComponents ) , `UiIModelComponents.initialize already called` ) ; return ; } enablePatches ( ) ; await IModelApp . localization ?. registerNamespace ( UiIModelComponents . localizationNamespace ) ; if ( ! IModelApp . localization ) { const localization = new EmptyLocalization ( ) ; await localization . initialize ( ) ; await UiComponents . initialize ( localization ) ; } else { await UiComponents . initialize ( IModelApp . localization ) ; } UiIModelComponents . _initialized = true ; } /** Unregisters the UiIModelComponents localization namespace */ public static terminate ( ) { IModelApp . localization ?. unregisterNamespace ( UiIModelComponents . localizationNamespace ) ; UiComponents . terminate ( ) ; UiIModelComponents . _initialized = false ; } /** Determines if UiIModelComponents has been initialized */ public static get initialized ( ) : boolean { return UiIModelComponents . _initialized ; } /** The internationalization service namespace. */ public static get localizationNamespace ( ) : string { return "UiIModelComponents" ; } internal public static get packageName ( ) : string { return "imodel-components-react" ; } internal public static translate ( key ) { if ( ! UiIModelComponents . initialized || ! IModelApp . localization ) { Logger . logError ( UiIModelComponents . loggerCategory ( this ) , `translate: IModelApp.localization has not been setup. Returning blank string.` ) ; return "" ; } return IModelApp . localization . getLocalizedStringWithNamespace ( UiIModelComponents . localizationNamespace , key ) ; } internal public static loggerCategory ( obj ) { const className = getClassName ( obj ) ; const category = UiIModelComponents . packageName + ( className ? `.${ className }` : "" ) ; return category ; } }