88 lines
3.3 KiB
TypeScript
Raw Normal View History

2024-01-04 20:17:54 -05:00
import { Suspense } from "react";
2023-11-03 12:06:55 +03:00
import { Routes, Route, Outlet } from "react-router-dom";
import Home from "./pages/Home";
import About from "./pages/About";
import Dashboard from "./pages/Dashboard";
2024-01-28 19:14:53 +01:00
import Dynamic from "./pages/Dynamic";
2024-01-04 20:17:54 -05:00
import ToPdf from "./pages/convert/ToPdf";
import Impose from "./pages/page-operations/Impose";
2023-11-03 12:06:55 +03:00
import NoMatch from "./pages/NoMatch";
import NavBar from "./components/NavBar";
2024-01-04 20:17:54 -05:00
import "bootstrap/dist/css/bootstrap.min.css";
import { Container } from "react-bootstrap";
import { useTranslation, initReactI18next } from "react-i18next";
2024-01-04 20:17:54 -05:00
import LanguageDetector from "i18next-browser-languagedetector";
2024-01-28 19:14:53 +01:00
import i18next from "i18next";
import resourcesToBackend from "i18next-resources-to-backend";
i18next.use(LanguageDetector).use(initReactI18next).use(resourcesToBackend((language: string, namespace: string) => import(`../../shared-operations/public/locales/${namespace}/${language}.json`)))
.init({
debug: true,
ns: ["common"], // Preload this namespace, no need to add the others, they will load once their module is loaded
defaultNS: "common",
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
initImmediate: false // Makes loading blocking but sync
2024-01-28 19:14:53 +01:00
}); // TODO: use i18next.config.ts instead
2024-01-26 16:26:04 +01:00
import "./general.css";
2023-11-03 12:06:55 +03:00
export default function App() {
2024-01-04 20:17:54 -05:00
return (
<Suspense fallback="loading">
{/* Routes nest inside one another. Nested route paths build upon
2023-11-03 12:06:55 +03:00
parent route paths, and nested route elements render inside
parent route elements. See the note about <Outlet> below. */}
2024-01-04 20:17:54 -05:00
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="dashboard" element={<Dashboard />} />
2024-01-28 19:14:53 +01:00
<Route path="dynamic" element={<Dynamic />} />
2023-11-03 12:06:55 +03:00
2024-01-04 20:17:54 -05:00
{/* Using path="*"" means "match anything", so this route
2023-11-03 12:06:55 +03:00
acts like a catch-all for URLs that we don't have explicit
routes for. */}
2024-01-04 20:17:54 -05:00
<Route path="*" element={<NoMatch />} />
</Route>
<Route path="/convert" element={<Layout />}>
<Route path="file-to-pdf" element={<ToPdf />} />
<Route path="*" element={<NoMatch />} />
</Route>
<Route path="/page-operations" element={<Layout />}>
<Route path="impose" element={<Impose />} />
<Route path="*" element={<NoMatch />} />
</Route>
</Routes>
</Suspense>
);
2023-11-03 12:06:55 +03:00
}
2023-10-28 19:56:16 +03:00
2023-11-03 12:06:55 +03:00
function Layout() {
2024-01-04 20:17:54 -05:00
const { t } = useTranslation();
2024-01-28 21:22:59 +01:00
console.log(t("inputs.pdffile.name"));
2024-01-04 20:17:54 -05:00
return (
<div lang-direction={t("language.direction")}>
<NavBar/>
2023-10-29 20:19:59 +02:00
2024-01-04 20:17:54 -05:00
{/* An <Outlet> renders whatever child route is currently active,
2023-11-03 12:06:55 +03:00
so you can think about this <Outlet> as a placeholder for
the child routes we defined above. */}
2024-01-04 20:17:54 -05:00
<Container fluid="sm" className="">
<div className="row justify-content-center">
<div className="col-md-6">
<Outlet/>
</div>
</div>
</Container>
</div>
2024-01-04 20:17:54 -05:00
);
2023-10-28 19:56:16 +03:00
}