import LoadingIndicator from "./LoadingIndicator";
import { usePlatformLanguage } from "../i18n/LanguageContext";

type PageTitleProps = {
  children: React.ReactNode;
  loading?: boolean;
};

export default function PageTitle({ children, loading = false }: PageTitleProps) {
  const { translateText } = usePlatformLanguage();
  const renderedChildren = typeof children === "string" ? translateText(children) : children;
  return (
    <h1 className="page-title-with-loader">
      <span>{renderedChildren}</span>
      {loading && <LoadingIndicator label="i18n:govoplan-core.loading_page_data.85fe9edf" />}
    </h1>);

}