npm package diff

Package: @forge/react

Versions: 10.5.3-next.0-experimental-c7a7d36 - 10.6.0-next.1

File: package/out/hooks/useTranslation.d.ts

Index: package/out/hooks/useTranslation.d.ts
===================================================================
--- package/out/hooks/useTranslation.d.ts
+++ package/out/hooks/useTranslation.d.ts
@@ -0,0 +1,49 @@
+import React, { type PropsWithChildren } from 'react';
+import { type ForgeSupportedLocaleCode } from '@forge/i18n';
+import { i18n } from '@forge/bridge';
+/**
+ * Represents the value of the i18n context.
+ *
+ * This type can be in one of two states:
+ * - Not ready: The translation function (`t`) is available, but the context is not fully initialized.
+ * - Ready: The translation function (`t`) is available, and the context is fully initialized with the current locale.
+ *
+ * @property ready Indicates whether the i18n context is fully initialized.
+ * @property t The translation function to translate i18n keys into localized strings.
+ * @property locale The current locale, available only when the context is ready.
+ */
+export declare type I18nContextValue = {
+    ready: false;
+    t: i18n.TranslationFunction;
+} | {
+    ready: true;
+    t: i18n.TranslationFunction;
+    locale: ForgeSupportedLocaleCode;
+};
+/**
+ * Custom hook to access the i18n translation context.
+ *
+ * This hook provides the current i18n context value, which includes the translation function (`t`)
+ * and the readiness state of the i18n context. If the context is not ready, the translation function
+ * will return the key itself.
+ *
+ * @returns The current i18n context value, including the translation function, current locale, and readiness state.
+ */
+export declare const useTranslation: () => I18nContextValue;
+/**
+ * Provider component for the i18n context.
+ *
+ * This component initializes the i18n context with the appropriate locale and translation function.
+ * It fetches the locale from the provided props or the current view context if no locale is provided.
+ * The i18n context value is then made available to all child components.
+ *
+ * @param children The child components that will have access to the i18n context.
+ * @param locale The optional locale to initialize the i18n context with,
+ *    if not provided, the current locale from the view context is used.
+ *
+ * @returns The provider component that wraps the children with the i18n context.
+ */
+export declare const I18nProvider: React.FC<PropsWithChildren<{
+    locale?: ForgeSupportedLocaleCode;
+}>>;
+//# sourceMappingURL=useTranslation.d.ts.map
\ No newline at end of file