frontend-app-api: register appLanguageApi and translationApi
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -57,9 +57,14 @@ import {
|
||||
ApiFactoryRegistry,
|
||||
ApiProvider,
|
||||
ApiResolver,
|
||||
AppThemeSelector,
|
||||
} from '@backstage/core-app-api';
|
||||
|
||||
import {
|
||||
AppLanguageSelector,
|
||||
AppThemeSelector,
|
||||
I18nextTranslationApi,
|
||||
} from '@backstage/core-app-api/alpha';
|
||||
|
||||
// TODO: Get rid of all of these
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { AppThemeProvider } from '../../../core-app-api/src/app/AppThemeProvider';
|
||||
@@ -86,6 +91,10 @@ import { SidebarItem } from '@backstage/core-components';
|
||||
import { DarkTheme, LightTheme } from '../extensions/themes';
|
||||
import { extractRouteInfoFromInstanceTree } from '../routing/extractRouteInfoFromInstanceTree';
|
||||
import { getOrCreateGlobalSingleton } from '@backstage/version-bridge';
|
||||
import {
|
||||
appLanguageApiRef,
|
||||
translationApiRef,
|
||||
} from '@backstage/core-plugin-api/alpha';
|
||||
|
||||
/** @public */
|
||||
export interface ExtensionTreeNode {
|
||||
@@ -474,6 +483,21 @@ function createApiHolder(
|
||||
factory: () => configApi,
|
||||
});
|
||||
|
||||
factoryRegistry.register('static', {
|
||||
api: appLanguageApiRef,
|
||||
deps: {},
|
||||
factory: () => AppLanguageSelector.createWithStorage(),
|
||||
});
|
||||
|
||||
factoryRegistry.register('default', {
|
||||
api: translationApiRef,
|
||||
deps: { languageApi: appLanguageApiRef },
|
||||
factory: ({ languageApi }) =>
|
||||
I18nextTranslationApi.create({
|
||||
languageApi,
|
||||
}),
|
||||
});
|
||||
|
||||
// TODO: ship these as default extensions instead
|
||||
for (const factory of defaultApis as AnyApiFactory[]) {
|
||||
if (!factoryRegistry.register('app', factory)) {
|
||||
|
||||
Reference in New Issue
Block a user