feat: add support for all languages from old homarr (#1394)
* 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
This commit is contained in:
@@ -1,14 +1,25 @@
|
||||
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 { useI18nMessages } from "@homarr/translation/client";
|
||||
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 messages = useI18nMessages();
|
||||
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: messages.common.mantineReactTable,
|
||||
localization: mantineReactTable,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user