Fixe The missing buttons
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
import { usePage } from '@inertiajs/react';
|
import { usePage } from '@inertiajs/react';
|
||||||
import {
|
import { cloneElement, isValidElement, useCallback, useMemo } from 'react';
|
||||||
Children,
|
|
||||||
cloneElement,
|
|
||||||
isValidElement,
|
|
||||||
useCallback,
|
|
||||||
useMemo,
|
|
||||||
} from 'react';
|
|
||||||
import type { ReactElement, ReactNode } from 'react';
|
import type { ReactElement, ReactNode } from 'react';
|
||||||
import type { TranslationReplacements, Translations } from '@/types';
|
import type { TranslationReplacements, Translations } from '@/types';
|
||||||
|
|
||||||
@@ -32,16 +26,19 @@ export function translateChildren(
|
|||||||
children: ReactNode,
|
children: ReactNode,
|
||||||
translate: Translate,
|
translate: Translate,
|
||||||
): ReactNode {
|
): ReactNode {
|
||||||
return Children.map(children, (child) => {
|
if (Array.isArray(children)) {
|
||||||
if (typeof child === 'string') {
|
return children.map((child) => translateChildren(child, translate));
|
||||||
return translateTextNode(child, translate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isValidElement(child)) {
|
if (typeof children === 'string') {
|
||||||
return child;
|
return translateTextNode(children, translate);
|
||||||
}
|
}
|
||||||
|
|
||||||
const element = child as ReactElement<{ children?: ReactNode }>;
|
if (!isValidElement(children)) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
const element = children as ReactElement<{ children?: ReactNode }>;
|
||||||
|
|
||||||
if (!element.props.children) {
|
if (!element.props.children) {
|
||||||
return element;
|
return element;
|
||||||
@@ -52,7 +49,6 @@ export function translateChildren(
|
|||||||
undefined,
|
undefined,
|
||||||
translateChildren(element.props.children, translate),
|
translateChildren(element.props.children, translate),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useTranslation(): {
|
export function useTranslation(): {
|
||||||
|
|||||||
Reference in New Issue
Block a user