Change i18n package to paraglideJs

also refactor auth provider
This commit is contained in:
2026-01-07 22:26:48 +07:00
parent 391acd282b
commit d49c37848f
47 changed files with 887 additions and 1060 deletions

View File

@@ -1,6 +1,6 @@
import NotFound from '@/components/NotFound';
import { Toaster } from '@/components/ui/sonner';
import { setSSRLanguage } from '@/lib/i18n';
import { getLocale } from '@/paraglide/runtime';
import { sessionQueries } from '@/service/queries';
import {
CheckIcon,
@@ -11,13 +11,12 @@ import {
import { TanStackDevtools } from '@tanstack/react-devtools';
import type { QueryClient } from '@tanstack/react-query';
import {
createRootRouteWithContext,
HeadContent,
Scripts,
createRootRouteWithContext,
} from '@tanstack/react-router';
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools';
import React from 'react';
import { useTranslation } from 'react-i18next';
import TanStackQueryDevtools from '../integrations/tanstack-query/devtools';
import appCss from '../styles.css?url';
@@ -30,7 +29,6 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
const userSession = await context.queryClient.fetchQuery(
sessionQueries.user(),
);
await setSSRLanguage();
return { userSession };
},
head: () => ({
@@ -61,29 +59,19 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
});
function RootDocument({ children }: { children: React.ReactNode }) {
const { i18n } = useTranslation();
return (
<html lang={i18n.language}>
<html lang={getLocale()}>
<head>
<HeadContent />
</head>
<body>
{children}
<Toaster
richColors
// richColors
visibleToasts={5}
position={'top-right'}
offset={{ top: 60, right: 10 }}
closeButton={true}
toastOptions={{
classNames: {
success: '!bg-green-50',
error: '!bg-red-50',
info: '!bg-blue-50',
warning: '!bg-yellow-50',
},
}}
icons={{
success: <CheckIcon className="text-green-500" size={16} />,
error: <WarningOctagonIcon className="text-red-500" size={16} />,