diff --git a/packages/core-app-api/api-report.md b/packages/core-app-api/api-report.md index 1b5a5b4798..bd99874a71 100644 --- a/packages/core-app-api/api-report.md +++ b/packages/core-app-api/api-report.md @@ -223,8 +223,8 @@ export type AppOptions = { configLoader?: AppConfigLoader; bindRoutes?(context: { bind: AppRouteBinder }): void; __experimentalTranslations?: { - fallbackLanguage?: string | string[]; - supportedLanguages?: string[]; + defaultLanguage?: string; + availableLanguages?: string[]; resources?: Array; }; }; diff --git a/packages/core-plugin-api/alpha-api-report.md b/packages/core-plugin-api/alpha-api-report.md index f186c36b7f..d689184083 100644 --- a/packages/core-plugin-api/alpha-api-report.md +++ b/packages/core-plugin-api/alpha-api-report.md @@ -5,19 +5,27 @@ ```ts import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/core-plugin-api'; -import { i18n } from 'i18next'; +import { Observable } from '@backstage/types'; import { ReactNode } from 'react'; import { TranslationMessages as TranslationMessages_2 } from '@backstage/core-plugin-api/alpha'; import { TranslationRef as TranslationRef_2 } from '@backstage/core-plugin-api/alpha'; // @alpha (undocumented) -export type AppTranslationApi = { - getI18n(): i18n; - addResource(resource: TranslationRef): void; +export type AppLanguageApi = { + getAvailableLanguages(): { + languages: string[]; + }; + setLanguage(language?: string): void; + getLanguage(): { + language: string; + }; + language$(): Observable<{ + language: string; + }>; }; // @alpha (undocumented) -export const appTranslationApiRef: ApiRef; +export const appLanguageApiRef: ApiRef; // @alpha export function createTranslationMessages< @@ -77,6 +85,37 @@ export interface PluginOptionsProviderProps { // @alpha export const PluginProvider: (props: PluginOptionsProviderProps) => JSX.Element; +// @alpha (undocumented) +export type TranslationApi = { + getTranslation< + TMessages extends { + [key in string]: string; + }, + >( + translationRef: TranslationRef, + ): TranslationSnapshot; + translation$< + TMessages extends { + [key in string]: string; + }, + >( + translationRef: TranslationRef, + ): Observable>; +}; + +// @alpha (undocumented) +export const translationApiRef: ApiRef; + +// @alpha (undocumented) +export type TranslationFunction< + TMessages extends { + [key in string]: string; + }, +> = ( + key: TKey, + options?: TranslationOptions, +) => TMessages[TKey]; + // @alpha export interface TranslationMessages< TId extends string = string, @@ -188,6 +227,20 @@ export interface TranslationResourceOptions< translations: TTranslations; } +// @alpha (undocumented) +export type TranslationSnapshot< + TMessages extends { + [key in string]: string; + }, +> = + | { + ready: false; + } + | { + ready: true; + t: TranslationFunction; + }; + // @alpha export function usePluginOptions< TPluginOptions extends {} = {}, @@ -200,10 +253,9 @@ export const useTranslationRef: < }, >( translationRef: TranslationRef, -) => ( - key: TKey, - options?: TranslationOptions, -) => TMessages[TKey]; +) => { + t: TranslationFunction; +}; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/test-utils/alpha-api-report.md b/packages/test-utils/alpha-api-report.md index c37d79279c..4a9fd2e5a4 100644 --- a/packages/test-utils/alpha-api-report.md +++ b/packages/test-utils/alpha-api-report.md @@ -3,13 +3,37 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { Observable } from '@backstage/types'; import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; +import { TranslationApi } from '@backstage/core-plugin-api/alpha'; +import { TranslationRef } from '@backstage/core-plugin-api/alpha'; +import { TranslationSnapshot } from '@backstage/core-plugin-api/alpha'; // @alpha export const MockPluginProvider: ({ children, }: PropsWithChildren<{}>) => React_2.JSX.Element; +// @alpha (undocumented) +export class MockTranslationApi implements TranslationApi { + // (undocumented) + static create(): MockTranslationApi; + // (undocumented) + getTranslation< + TMessages extends { + [key in string]: string; + }, + >( + translationRef: TranslationRef, + ): TranslationSnapshot; + // (undocumented) + translation$< + TMessages extends { + [key in string]: string; + }, + >(): Observable>; +} + // (No @packageDocumentation comment for this package) ```