import React from 'react';
import { useTranslateLabel } from './useTranslateLabel';
import { TestTranslationProvider } from './TestTranslationProvider';
import { SourceContextProvider } from '../core';
export default {
title: 'ra-core/i18n/useTranslateLabel',
};
const TranslateLabel = ({
source,
label,
resource,
}: {
source?: string;
label?: React.ReactNode;
resource?: string;
}) => {
const translateLabel = useTranslateLabel();
return (
<>
{translateLabel({
label,
source,
resource,
})}
>
);
};
export const Basic = () => (
m}>
);
export const Source = () => (
m}>
);
export const Resource = () => (
m}>
);
export const LabelFalse = () => (
);
export const LabelEmpty = () => (
);
export const LabelElement = () => (
My title}
source="title"
resource="posts"
/>
);
export const LabelText = () => (
);
export const I18nTranslation = () => (
);
export const I18nLabelAsKey = () => (
);
export const I18nNoTranslation = () => (
);
export const InSourceContext = () => (
source,
getLabel: source => `test.${source}`,
}}
>
);
export const InSourceContextI18nKey = () => (
m}>
source,
getLabel: source => `test.${source}`,
}}
>
);
export const InSourceContextNoTranslation = () => (
source,
getLabel: source => `test.${source}`,
}}
>
);
export const InSourceContextWithResource = () => (
source,
getLabel: source => `test.${source}`,
}}
>
);