* feat: add support for all languages from old homarr * fix: add mantine-react-table translations, remove arabic language * refactor: change translations to json for better crowdin support * fix: issues with loading dayjs and mantine-react-table translations * chore: add additional translations with variables * fix: format and deepsource issues * fix: test failing because of missing coverage exclusions * fix: format issues * fix: format issue
26 lines
955 B
TypeScript
26 lines
955 B
TypeScript
import { useParams } from "next/navigation";
|
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
import type { MRT_RowData, MRT_TableOptions } from "mantine-react-table";
|
|
import { useMantineReactTable } from "mantine-react-table";
|
|
|
|
import type { SupportedLanguage } from "@homarr/translation";
|
|
import { localeConfigurations } from "@homarr/translation";
|
|
|
|
export const useTranslatedMantineReactTable = <TData extends MRT_RowData>(
|
|
tableOptions: Omit<MRT_TableOptions<TData>, "localization">,
|
|
) => {
|
|
const { locale } = useParams<{ locale: SupportedLanguage }>();
|
|
const { data: mantineReactTable } = useSuspenseQuery({
|
|
queryKey: ["mantine-react-table-locale", locale],
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
queryFn: async () => {
|
|
return await localeConfigurations[locale].importMrtLocalization();
|
|
},
|
|
});
|
|
|
|
return useMantineReactTable<TData>({
|
|
...tableOptions,
|
|
localization: mantineReactTable,
|
|
});
|
|
};
|