packageDocumentation module /** 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" ; import type { Localization } from "@itwin/core-common" ; import { getClassName , UiError } from "@itwin/appui-abstract" ; public export class UiCore { private static _initialized = false ; private static _localization ? : Localization ; param localization public 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 */ public static terminate ( ) { if ( UiCore . _localization ) UiCore . _localization . unregisterNamespace ( UiCore . localizationNamespace ) ; UiCore . _localization = undefined ; UiCore . _initialized = false ; } /** Determines if UiCore has been initialized */ public static get initialized ( ) : boolean { return UiCore . _initialized ; } internal public static get localization ( ) : Localization { if ( ! UiCore . _localization ) throw new UiError ( UiCore . loggerCategory ( this ) , "localization: UiCore.initialize has not been called. Unable to return Localization object." ) ; return UiCore . _localization ; } /** The internationalization service namespace. */ public static get localizationNamespace ( ) : string { return "UiCore" ; } internal public static translate ( key ) { if ( ! UiCore . _localization ) { Logger . logError ( UiCore . loggerCategory ( this ) , `translate: UiCore must be initialize with a localization provider. Returning blank string.` ) ; return "" ; } return UiCore . _localization . getLocalizedStringWithNamespace ( UiCore . localizationNamespace , key ) ; } internal public static get packageName ( ) : string { return "core-react" ; } internal public static loggerCategory ( obj ) { const className = getClassName ( obj ) ; const category = UiCore . packageName + ( className ? `.${ className }` : "" ) ; return category ; } }