@lastbrain/app 2.0.18 → 2.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-shell/not-found.js +2 -2
- package/dist/components/LanguageSwitcher.d.ts +7 -0
- package/dist/components/LanguageSwitcher.d.ts.map +1 -0
- package/dist/components/LanguageSwitcher.js +62 -0
- package/dist/config/version.d.ts.map +1 -1
- package/dist/config/version.js +19 -21
- package/dist/i18n/LanguageProvider.d.ts +4 -0
- package/dist/i18n/LanguageProvider.d.ts.map +1 -0
- package/dist/i18n/LanguageProvider.js +6 -0
- package/dist/i18n/TranslationsScript.d.ts +8 -0
- package/dist/i18n/TranslationsScript.d.ts.map +1 -0
- package/dist/i18n/TranslationsScript.js +10 -0
- package/dist/i18n/cookies.d.ts +6 -0
- package/dist/i18n/cookies.d.ts.map +1 -0
- package/dist/i18n/cookies.js +24 -0
- package/dist/i18n/langHrefHelper.d.ts +36 -0
- package/dist/i18n/langHrefHelper.d.ts.map +1 -0
- package/dist/i18n/langHrefHelper.js +41 -0
- package/dist/i18n/server-helpers.d.ts +33 -0
- package/dist/i18n/server-helpers.d.ts.map +1 -0
- package/dist/i18n/server-helpers.js +39 -0
- package/dist/i18n/server-lang.d.ts +10 -0
- package/dist/i18n/server-lang.d.ts.map +1 -0
- package/dist/i18n/server-lang.js +42 -0
- package/dist/i18n/server.d.ts +10 -0
- package/dist/i18n/server.d.ts.map +1 -0
- package/dist/i18n/server.js +8 -0
- package/dist/i18n/types.d.ts +38 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +4 -0
- package/dist/i18n/useLangRouter.d.ts +12 -0
- package/dist/i18n/useLangRouter.d.ts.map +1 -0
- package/dist/i18n/useLangRouter.js +18 -0
- package/dist/i18n/useLink.d.ts +34 -0
- package/dist/i18n/useLink.d.ts.map +1 -0
- package/dist/i18n/useLink.js +58 -0
- package/dist/i18n/useModuleTranslation.d.ts +11 -0
- package/dist/i18n/useModuleTranslation.d.ts.map +1 -0
- package/dist/i18n/useModuleTranslation.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/layouts/AdminLayout.js +1 -1
- package/dist/layouts/AppProviders.d.ts +4 -1
- package/dist/layouts/AppProviders.d.ts.map +1 -1
- package/dist/layouts/AppProviders.js +18 -8
- package/dist/layouts/AuthLayout.js +1 -1
- package/dist/layouts/AuthLayoutWithSidebar.d.ts.map +1 -1
- package/dist/layouts/AuthLayoutWithSidebar.js +5 -3
- package/dist/layouts/RootLayout.d.ts +4 -1
- package/dist/layouts/RootLayout.d.ts.map +1 -1
- package/dist/layouts/RootLayout.js +2 -2
- package/dist/scripts/i18n-build.d.ts +7 -0
- package/dist/scripts/i18n-build.d.ts.map +1 -0
- package/dist/scripts/i18n-build.js +100 -0
- package/dist/scripts/init-app.js +12 -12
- package/dist/scripts/module-build.d.ts.map +1 -1
- package/dist/scripts/module-build.js +390 -81
- package/dist/styles.css +1 -1
- package/dist/templates/DefaultDoc.d.ts.map +1 -1
- package/dist/templates/DefaultDoc.js +90 -2
- package/dist/templates/middleware-i18n.example.d.ts +16 -0
- package/dist/templates/middleware-i18n.example.d.ts.map +1 -0
- package/dist/templates/middleware-i18n.example.js +72 -0
- package/package.json +36 -23
- package/src/app-shell/not-found.tsx +2 -2
- package/src/components/LanguageSwitcher.tsx +156 -0
- package/src/config/version.ts +19 -21
- package/src/i18n/LanguageProvider.tsx +7 -0
- package/src/i18n/README_LANG_HELPERS.md +187 -0
- package/src/i18n/TranslationsScript.tsx +17 -0
- package/src/i18n/cookies.ts +24 -0
- package/src/i18n/langHrefHelper.ts +51 -0
- package/src/i18n/server-helpers.ts +48 -0
- package/src/i18n/server-lang.ts +51 -0
- package/src/i18n/server.ts +13 -0
- package/src/i18n/types.ts +39 -0
- package/src/i18n/useLangRouter.ts +21 -0
- package/src/i18n/useLink.ts +60 -0
- package/src/i18n/useModuleTranslation.ts +27 -0
- package/src/index.ts +20 -0
- package/src/layouts/AdminLayout.tsx +1 -1
- package/src/layouts/AppProviders.tsx +35 -16
- package/src/layouts/AuthLayout.tsx +1 -1
- package/src/layouts/AuthLayoutWithSidebar.tsx +5 -3
- package/src/layouts/RootLayout.tsx +12 -5
- package/src/scripts/i18n-build.ts +122 -0
- package/src/scripts/init-app.ts +12 -12
- package/src/scripts/module-build.ts +485 -94
- package/src/templates/DefaultDoc.tsx +511 -1
- package/src/templates/middleware-i18n.example.ts +92 -0
- package/dist/app-shell/(admin)/dashboard/page.d.ts +0 -2
- package/dist/app-shell/(admin)/dashboard/page.d.ts.map +0 -1
- package/dist/app-shell/(admin)/dashboard/page.js +0 -5
- package/dist/app-shell/(admin)/page.d.ts +0 -2
- package/dist/app-shell/(admin)/page.d.ts.map +0 -1
- package/dist/app-shell/(admin)/page.js +0 -5
- package/dist/app-shell/(auth)/dashboard/page.d.ts +0 -2
- package/dist/app-shell/(auth)/dashboard/page.d.ts.map +0 -1
- package/dist/app-shell/(auth)/dashboard/page.js +0 -5
- package/dist/app-shell/(auth)/page.d.ts +0 -2
- package/dist/app-shell/(auth)/page.d.ts.map +0 -1
- package/dist/app-shell/(auth)/page.js +0 -5
- package/dist/components/TableStructure.d.ts +0 -8
- package/dist/components/TableStructure.d.ts.map +0 -1
- package/dist/components/TableStructure.js +0 -37
- package/dist/hooks/useNotificationsSimple.d.ts +0 -20
- package/dist/hooks/useNotificationsSimple.d.ts.map +0 -1
- package/dist/hooks/useNotificationsSimple.js +0 -37
- package/dist/module-build.d.ts +0 -2
- package/dist/module-build.d.ts.map +0 -1
- package/dist/module-build.js +0 -50
- package/dist/modules/index.d.ts +0 -3
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js +0 -2
- package/dist/src/__tests__/module-registry.test.d.ts +0 -2
- package/dist/src/__tests__/module-registry.test.d.ts.map +0 -1
- package/dist/src/__tests__/module-registry.test.js +0 -53
- package/dist/src/app-shell/(admin)/layout.d.ts +0 -4
- package/dist/src/app-shell/(admin)/layout.d.ts.map +0 -1
- package/dist/src/app-shell/(admin)/layout.js +0 -5
- package/dist/src/app-shell/(auth)/layout.d.ts +0 -4
- package/dist/src/app-shell/(auth)/layout.d.ts.map +0 -1
- package/dist/src/app-shell/(auth)/layout.js +0 -5
- package/dist/src/app-shell/(public)/page.d.ts +0 -2
- package/dist/src/app-shell/(public)/page.d.ts.map +0 -1
- package/dist/src/app-shell/(public)/page.js +0 -5
- package/dist/src/app-shell/layout.d.ts +0 -3
- package/dist/src/app-shell/layout.d.ts.map +0 -1
- package/dist/src/app-shell/layout.js +0 -3
- package/dist/src/app-shell/not-found.d.ts +0 -2
- package/dist/src/app-shell/not-found.d.ts.map +0 -1
- package/dist/src/app-shell/not-found.js +0 -10
- package/dist/src/auth/authHelpers.d.ts +0 -7
- package/dist/src/auth/authHelpers.d.ts.map +0 -1
- package/dist/src/auth/authHelpers.js +0 -19
- package/dist/src/auth/useAuthSession.d.ts +0 -7
- package/dist/src/auth/useAuthSession.d.ts.map +0 -1
- package/dist/src/auth/useAuthSession.js +0 -49
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -143
- package/dist/src/components/NotificationContainer.d.ts +0 -2
- package/dist/src/components/NotificationContainer.d.ts.map +0 -1
- package/dist/src/components/NotificationContainer.js +0 -8
- package/dist/src/hooks/useNotifications.d.ts +0 -30
- package/dist/src/hooks/useNotifications.d.ts.map +0 -1
- package/dist/src/hooks/useNotifications.js +0 -165
- package/dist/src/index.d.ts +0 -22
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -22
- package/dist/src/layouts/AdminLayout.d.ts +0 -4
- package/dist/src/layouts/AdminLayout.d.ts.map +0 -1
- package/dist/src/layouts/AdminLayout.js +0 -4
- package/dist/src/layouts/AdminLayoutWithSidebar.d.ts +0 -10
- package/dist/src/layouts/AdminLayoutWithSidebar.d.ts.map +0 -1
- package/dist/src/layouts/AdminLayoutWithSidebar.js +0 -62
- package/dist/src/layouts/AppProviders.d.ts +0 -27
- package/dist/src/layouts/AppProviders.d.ts.map +0 -1
- package/dist/src/layouts/AppProviders.js +0 -48
- package/dist/src/layouts/AuthLayout.d.ts +0 -4
- package/dist/src/layouts/AuthLayout.d.ts.map +0 -1
- package/dist/src/layouts/AuthLayout.js +0 -4
- package/dist/src/layouts/AuthLayoutWithSidebar.d.ts +0 -12
- package/dist/src/layouts/AuthLayoutWithSidebar.d.ts.map +0 -1
- package/dist/src/layouts/AuthLayoutWithSidebar.js +0 -60
- package/dist/src/layouts/PublicLayout.d.ts +0 -8
- package/dist/src/layouts/PublicLayout.d.ts.map +0 -1
- package/dist/src/layouts/PublicLayout.js +0 -6
- package/dist/src/layouts/PublicLayoutWithSidebar.d.ts +0 -9
- package/dist/src/layouts/PublicLayoutWithSidebar.d.ts.map +0 -1
- package/dist/src/layouts/PublicLayoutWithSidebar.js +0 -60
- package/dist/src/layouts/RootLayout.d.ts +0 -6
- package/dist/src/layouts/RootLayout.d.ts.map +0 -1
- package/dist/src/layouts/RootLayout.js +0 -9
- package/dist/src/modules/module-loader.d.ts +0 -5
- package/dist/src/modules/module-loader.d.ts.map +0 -1
- package/dist/src/modules/module-loader.js +0 -10
- package/dist/src/scripts/db-init.d.ts +0 -2
- package/dist/src/scripts/db-init.d.ts.map +0 -1
- package/dist/src/scripts/db-init.js +0 -300
- package/dist/src/scripts/db-migrations-sync.d.ts +0 -2
- package/dist/src/scripts/db-migrations-sync.d.ts.map +0 -1
- package/dist/src/scripts/db-migrations-sync.js +0 -84
- package/dist/src/scripts/dev-sync.d.ts +0 -2
- package/dist/src/scripts/dev-sync.d.ts.map +0 -1
- package/dist/src/scripts/dev-sync.js +0 -194
- package/dist/src/scripts/init-app.d.ts +0 -12
- package/dist/src/scripts/init-app.d.ts.map +0 -1
- package/dist/src/scripts/init-app.js +0 -2175
- package/dist/src/scripts/module-add.d.ts +0 -2
- package/dist/src/scripts/module-add.d.ts.map +0 -1
- package/dist/src/scripts/module-add.js +0 -232
- package/dist/src/scripts/module-build.d.ts +0 -2
- package/dist/src/scripts/module-build.d.ts.map +0 -1
- package/dist/src/scripts/module-build.js +0 -1280
- package/dist/src/scripts/module-create.d.ts +0 -28
- package/dist/src/scripts/module-create.d.ts.map +0 -1
- package/dist/src/scripts/module-create.js +0 -1429
- package/dist/src/scripts/module-delete.d.ts +0 -6
- package/dist/src/scripts/module-delete.d.ts.map +0 -1
- package/dist/src/scripts/module-delete.js +0 -147
- package/dist/src/scripts/module-list.d.ts +0 -2
- package/dist/src/scripts/module-list.d.ts.map +0 -1
- package/dist/src/scripts/module-list.js +0 -61
- package/dist/src/scripts/module-remove.d.ts +0 -2
- package/dist/src/scripts/module-remove.d.ts.map +0 -1
- package/dist/src/scripts/module-remove.js +0 -311
- package/dist/src/scripts/readme-build.d.ts +0 -2
- package/dist/src/scripts/readme-build.d.ts.map +0 -1
- package/dist/src/scripts/readme-build.js +0 -39
- package/dist/src/scripts/script-runner.d.ts +0 -5
- package/dist/src/scripts/script-runner.d.ts.map +0 -1
- package/dist/src/scripts/script-runner.js +0 -25
- package/dist/src/templates/AuthGuidePage.d.ts +0 -2
- package/dist/src/templates/AuthGuidePage.d.ts.map +0 -1
- package/dist/src/templates/AuthGuidePage.js +0 -9
- package/dist/src/templates/DefaultDoc.d.ts +0 -2
- package/dist/src/templates/DefaultDoc.d.ts.map +0 -1
- package/dist/src/templates/DefaultDoc.js +0 -240
- package/dist/src/templates/DocPage.d.ts +0 -17
- package/dist/src/templates/DocPage.d.ts.map +0 -1
- package/dist/src/templates/DocPage.js +0 -193
- package/dist/src/templates/DocsPageWithModules.d.ts +0 -2
- package/dist/src/templates/DocsPageWithModules.d.ts.map +0 -1
- package/dist/src/templates/DocsPageWithModules.js +0 -8
- package/dist/src/templates/MigrationsGuidePage.d.ts +0 -2
- package/dist/src/templates/MigrationsGuidePage.d.ts.map +0 -1
- package/dist/src/templates/MigrationsGuidePage.js +0 -11
- package/dist/src/templates/ModuleGuidePage.d.ts +0 -2
- package/dist/src/templates/ModuleGuidePage.d.ts.map +0 -1
- package/dist/src/templates/ModuleGuidePage.js +0 -14
- package/dist/src/templates/SimpleDocPage.d.ts +0 -2
- package/dist/src/templates/SimpleDocPage.d.ts.map +0 -1
- package/dist/src/templates/SimpleDocPage.js +0 -28
- package/dist/src/templates/SimpleHomePage.d.ts +0 -6
- package/dist/src/templates/SimpleHomePage.d.ts.map +0 -1
- package/dist/src/templates/SimpleHomePage.js +0 -7
- package/dist/src/types/menu.d.ts +0 -23
- package/dist/src/types/menu.d.ts.map +0 -1
- package/dist/src/types/menu.js +0 -1
- package/dist/templates/HomePage.d.ts +0 -6
- package/dist/templates/HomePage.d.ts.map +0 -1
- package/dist/templates/HomePage.js +0 -6
- package/dist/templates/components/AppAside.d.ts +0 -6
- package/dist/templates/components/AppAside.d.ts.map +0 -1
- package/dist/templates/components/AppAside.js +0 -9
- package/dist/templates/layouts/admin-layout.d.ts +0 -4
- package/dist/templates/layouts/admin-layout.d.ts.map +0 -1
- package/dist/templates/layouts/admin-layout.js +0 -6
- package/dist/templates/layouts/auth-layout.d.ts +0 -4
- package/dist/templates/layouts/auth-layout.d.ts.map +0 -1
- package/dist/templates/layouts/auth-layout.js +0 -6
- package/dist/templates/migrations/20201010100000_init.sql +0 -123
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useLocalizedRouter } from "@lastbrain/core";
|
|
3
4
|
import { Button } from "@lastbrain/ui";
|
|
4
|
-
import { useRouter } from "next/navigation";
|
|
5
5
|
export default function NotFound() {
|
|
6
|
-
const router =
|
|
6
|
+
const router = useLocalizedRouter();
|
|
7
7
|
return (_jsx("div", { className: "flex min-h-screen items-center justify-center bg-background", children: _jsxs("div", { className: "mx-auto max-w-md text-center", children: [_jsx("h1", { className: "mb-4 text-6xl font-bold text-foreground", children: "404" }), _jsx("h2", { className: "mb-4 text-2xl font-semibold text-foreground", children: "Page non trouv\u00E9e" }), _jsx("p", { className: "mb-8 text-muted-foreground", children: "La page que vous recherchez n'existe pas ou a \u00E9t\u00E9 d\u00E9plac\u00E9e." }), _jsx(Button, { onPress: () => {
|
|
8
8
|
router.back();
|
|
9
9
|
}, className: "inline-flex items-center justify-center rounded-md bg-primary px-6 py-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90", children: "Retour \u00E0 l'accueil" })] }) }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface LanguageSwitcherProps {
|
|
2
|
+
variant?: "default" | "minimal";
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function LanguageSwitcher({ variant, className, }: LanguageSwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=LanguageSwitcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageSwitcher.d.ts","sourceRoot":"","sources":["../../src/components/LanguageSwitcher.tsx"],"names":[],"mappings":"AAaA,UAAU,qBAAqB;IAC7B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAmB,EACnB,SAAc,GACf,EAAE,qBAAqB,2CAsIvB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useLanguage } from "../i18n/LanguageProvider";
|
|
5
|
+
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Spinner, } from "@lastbrain/ui";
|
|
6
|
+
export function LanguageSwitcher({ variant = "default", className = "", }) {
|
|
7
|
+
const { lang, setLang } = useLanguage();
|
|
8
|
+
const [flagUrls, setFlagUrls] = useState({
|
|
9
|
+
fr: "",
|
|
10
|
+
en: "",
|
|
11
|
+
});
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
13
|
+
const [isHydrated, setIsHydrated] = useState(false);
|
|
14
|
+
// Marquer l'hydration comme terminée
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setIsHydrated(true);
|
|
17
|
+
}, []);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let canceled = false;
|
|
20
|
+
const objectUrls = [];
|
|
21
|
+
async function loadFlags() {
|
|
22
|
+
setLoading(true);
|
|
23
|
+
try {
|
|
24
|
+
const entries = await Promise.all(["fr", "en"].map(async (code) => {
|
|
25
|
+
const apiCode = code === "fr" ? "fr" : "gb";
|
|
26
|
+
const response = await fetch(`https://flagcdn.com/${apiCode}.svg`);
|
|
27
|
+
if (!response.ok)
|
|
28
|
+
throw new Error(`Flag fetch failed: ${code}`);
|
|
29
|
+
const blob = await response.blob();
|
|
30
|
+
const url = URL.createObjectURL(blob);
|
|
31
|
+
objectUrls.push(url);
|
|
32
|
+
return [code, url];
|
|
33
|
+
}));
|
|
34
|
+
if (!canceled) {
|
|
35
|
+
setFlagUrls(Object.fromEntries(entries));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (_err) {
|
|
39
|
+
if (!canceled) {
|
|
40
|
+
setFlagUrls({
|
|
41
|
+
fr: "https://flagcdn.com/fr.svg",
|
|
42
|
+
en: "https://flagcdn.com/gb.svg",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
if (!canceled)
|
|
48
|
+
setLoading(false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
loadFlags();
|
|
52
|
+
return () => {
|
|
53
|
+
canceled = true;
|
|
54
|
+
objectUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
const renderFlag = (code) => (_jsx("span", { className: "inline-flex items-center gap-2", children: flagUrls[code] ? (_jsx("img", { src: flagUrls[code], alt: code === "fr" ? "Drapeau français" : "Flag English", className: "h-4 w-6 rounded-sm border border-slate-200 object-cover" })) : isHydrated ? (_jsx("span", { className: "inline-flex h-4 w-6 items-center justify-center rounded-sm bg-slate-200 text-[10px] font-semibold text-slate-600", children: code.toUpperCase() })) : null }));
|
|
58
|
+
if (variant === "minimal") {
|
|
59
|
+
return (_jsxs(Dropdown, { size: "sm", className: "px-0 m-0", children: [_jsx(DropdownTrigger, { className: "px-0 m-0", children: renderFlag(lang) }), _jsxs(DropdownMenu, { children: [_jsxs(DropdownItem, { onPress: () => setLang("en"), startContent: renderFlag("en"), className: lang === "en" ? "bg-primary/10" : "", children: ["English ", isHydrated && lang === "en" && "✓"] }, "en"), _jsxs(DropdownItem, { onPress: () => setLang("fr"), startContent: renderFlag("fr"), className: lang === "fr" ? "bg-primary/10" : "", children: ["Fran\u00E7ais ", isHydrated && lang === "fr" && "✓"] }, "fr")] })] }));
|
|
60
|
+
}
|
|
61
|
+
return (_jsxs(Dropdown, { size: "sm", className: "px-0", children: [_jsx(DropdownTrigger, { className: "px-0 m-0", children: _jsx(Button, { variant: "light", size: "sm", className: "px-0 m-0", startContent: renderFlag(lang), endContent: loading ? _jsx(Spinner, { size: "sm" }) : null }) }), _jsxs(DropdownMenu, { children: [_jsxs(DropdownItem, { onPress: () => setLang("en"), className: lang === "en" ? "bg-primary/10" : "", children: [renderFlag("en"), " English ", isHydrated && lang === "en" && "✓"] }, "en"), _jsxs(DropdownItem, { onPress: () => setLang("fr"), className: lang === "fr" ? "bg-primary/10" : "", children: [renderFlag("fr"), " Fran\u00E7ais ", isHydrated && lang === "fr" && "✓"] }, "fr")] })] }));
|
|
62
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/config/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/config/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoBnD,CAAC"}
|
package/dist/config/version.js
CHANGED
|
@@ -4,25 +4,23 @@
|
|
|
4
4
|
* Mise à jour automatique lors de pnpm version:patch/minor/major
|
|
5
5
|
*/
|
|
6
6
|
export const PACKAGE_VERSIONS = {
|
|
7
|
-
"@lastbrain-labs/module-billing-pro": "^2.0.
|
|
8
|
-
"@lastbrain-labs/module-cj-analyzer-pro": "^0.1.
|
|
9
|
-
"@lastbrain-labs/module-core-cart-pro": "^2.0.
|
|
10
|
-
"@lastbrain-labs/module-core-commerce-pro": "^2.0.
|
|
11
|
-
"@lastbrain-labs/module-core-order-pro": "^2.0.
|
|
12
|
-
"@lastbrain-labs/module-core-payment-pro": "^2.0.
|
|
13
|
-
"@lastbrain-labs/module-core-product-pro": "^2.0.
|
|
14
|
-
"@lastbrain-labs/module-recipes-pro": "^2.0.
|
|
15
|
-
"@lastbrain-labs/module-shop-pro": "^0.1.
|
|
16
|
-
"@lastbrain/app": "^2.0.
|
|
17
|
-
"@lastbrain/core": "^2.0.
|
|
18
|
-
"@lastbrain/module-ai": "^2.0.
|
|
19
|
-
"@lastbrain/module-auth": "^2.0.
|
|
20
|
-
"@lastbrain/module-legal": "^2.0.
|
|
21
|
-
"@lastbrain/module-project-board": "^2.0.
|
|
22
|
-
"@lastbrain/module-tasks": "^2.0.
|
|
23
|
-
"@lastbrain/ui": "^2.0.
|
|
24
|
-
"apps/recipe": "^2.0.
|
|
25
|
-
"
|
|
26
|
-
"apps/test-module": "^2.0.10",
|
|
27
|
-
"lastbrain": "^2.0.10",
|
|
7
|
+
"@lastbrain-labs/module-billing-pro": "^2.0.18",
|
|
8
|
+
"@lastbrain-labs/module-cj-analyzer-pro": "^0.1.10",
|
|
9
|
+
"@lastbrain-labs/module-core-cart-pro": "^2.0.18",
|
|
10
|
+
"@lastbrain-labs/module-core-commerce-pro": "^2.0.18",
|
|
11
|
+
"@lastbrain-labs/module-core-order-pro": "^2.0.18",
|
|
12
|
+
"@lastbrain-labs/module-core-payment-pro": "^2.0.18",
|
|
13
|
+
"@lastbrain-labs/module-core-product-pro": "^2.0.18",
|
|
14
|
+
"@lastbrain-labs/module-recipes-pro": "^2.0.18",
|
|
15
|
+
"@lastbrain-labs/module-shop-pro": "^0.1.10",
|
|
16
|
+
"@lastbrain/app": "^2.0.21",
|
|
17
|
+
"@lastbrain/core": "^2.0.19",
|
|
18
|
+
"@lastbrain/module-ai": "^2.0.18",
|
|
19
|
+
"@lastbrain/module-auth": "^2.0.19",
|
|
20
|
+
"@lastbrain/module-legal": "^2.0.18",
|
|
21
|
+
"@lastbrain/module-project-board": "^2.0.18",
|
|
22
|
+
"@lastbrain/module-tasks": "^2.0.18",
|
|
23
|
+
"@lastbrain/ui": "^2.0.19",
|
|
24
|
+
"apps/recipe": "^2.0.11",
|
|
25
|
+
"lastbrain": "^2.0.11",
|
|
28
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageProvider.d.ts","sourceRoot":"","sources":["../../src/i18n/LanguageProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// Cette implémentation a été déplacée dans @lastbrain/core pour éviter les dépendances cycliques
|
|
3
|
+
// Réexport pour la compatibilité backward
|
|
4
|
+
export { LanguageProvider } from "@lastbrain/core";
|
|
5
|
+
export { useLanguage } from "@lastbrain/core";
|
|
6
|
+
export { LanguageContext } from "@lastbrain/core";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composant pour sérialiser les traductions dans le HTML
|
|
3
|
+
* Cela permet au client d'accéder aux traductions sans les repasser en props
|
|
4
|
+
*/
|
|
5
|
+
export declare function TranslationsScript({ translations, }: {
|
|
6
|
+
translations: Record<string, string>;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=TranslationsScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslationsScript.d.ts","sourceRoot":"","sources":["../../src/i18n/TranslationsScript.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,YAAY,GACb,EAAE;IACD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,2CAQA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Composant pour sérialiser les traductions dans le HTML
|
|
4
|
+
* Cela permet au client d'accéder aux traductions sans les repasser en props
|
|
5
|
+
*/
|
|
6
|
+
export function TranslationsScript({ translations, }) {
|
|
7
|
+
return (_jsx("script", { dangerouslySetInnerHTML: {
|
|
8
|
+
__html: `window.__TRANSLATIONS__ = ${JSON.stringify(translations)};`,
|
|
9
|
+
} }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/i18n/cookies.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAMlE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWrD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gestion des cookies pour la langue
|
|
3
|
+
*/
|
|
4
|
+
export function setCookie(name, value, days) {
|
|
5
|
+
if (typeof document === "undefined")
|
|
6
|
+
return;
|
|
7
|
+
const expires = new Date();
|
|
8
|
+
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
|
|
9
|
+
document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/`;
|
|
10
|
+
}
|
|
11
|
+
export function getCookie(name) {
|
|
12
|
+
if (typeof document === "undefined")
|
|
13
|
+
return null;
|
|
14
|
+
const nameEQ = `${name}=`;
|
|
15
|
+
const ca = document.cookie.split(";");
|
|
16
|
+
for (let i = 0; i < ca.length; i++) {
|
|
17
|
+
let c = ca[i];
|
|
18
|
+
while (c.charAt(0) === " ")
|
|
19
|
+
c = c.substring(1, c.length);
|
|
20
|
+
if (c.indexOf(nameEQ) === 0)
|
|
21
|
+
return c.substring(nameEQ.length, c.length);
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fichier utilitaire pour transformer des listes/objets avec hrefs
|
|
3
|
+
* Utile pour les données statiques qui n'ont pas accès au hook useLanguage
|
|
4
|
+
*/
|
|
5
|
+
import type { Language } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Transforme un tableau d'éléments avec des hrefs
|
|
8
|
+
* @param items - Tableau d'éléments contenant un champ href
|
|
9
|
+
* @param lang - Code de langue
|
|
10
|
+
* @returns Le tableau avec les hrefs transformés
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const menu = transformLangHrefs([
|
|
15
|
+
* { label: "Accueil", href: "/" },
|
|
16
|
+
* { label: "Recettes", href: "/recipes" }
|
|
17
|
+
* ], "fr");
|
|
18
|
+
* // Résultat: [
|
|
19
|
+
* // { label: "Accueil", href: "/fr" },
|
|
20
|
+
* // { label: "Recettes", href: "/fr/recipes" }
|
|
21
|
+
* // ]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function transformLangHrefs<T extends {
|
|
25
|
+
href?: string;
|
|
26
|
+
}>(items: T[], lang: Language): T[];
|
|
27
|
+
/**
|
|
28
|
+
* Transforme un seul élément avec un href
|
|
29
|
+
* @param item - Élément contenant un champ href
|
|
30
|
+
* @param lang - Code de langue
|
|
31
|
+
* @returns L'élément avec le href transformé
|
|
32
|
+
*/
|
|
33
|
+
export declare function transformLangHref<T extends {
|
|
34
|
+
href?: string;
|
|
35
|
+
}>(item: T, lang: Language): T;
|
|
36
|
+
//# sourceMappingURL=langHrefHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langHrefHelper.d.ts","sourceRoot":"","sources":["../../src/i18n/langHrefHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5D,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,QAAQ,GACb,CAAC,EAAE,CAKL;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3D,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,QAAQ,GACb,CAAC,CAKH"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fichier utilitaire pour transformer des listes/objets avec hrefs
|
|
3
|
+
* Utile pour les données statiques qui n'ont pas accès au hook useLanguage
|
|
4
|
+
*/
|
|
5
|
+
import { langHref } from "./useLink";
|
|
6
|
+
/**
|
|
7
|
+
* Transforme un tableau d'éléments avec des hrefs
|
|
8
|
+
* @param items - Tableau d'éléments contenant un champ href
|
|
9
|
+
* @param lang - Code de langue
|
|
10
|
+
* @returns Le tableau avec les hrefs transformés
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const menu = transformLangHrefs([
|
|
15
|
+
* { label: "Accueil", href: "/" },
|
|
16
|
+
* { label: "Recettes", href: "/recipes" }
|
|
17
|
+
* ], "fr");
|
|
18
|
+
* // Résultat: [
|
|
19
|
+
* // { label: "Accueil", href: "/fr" },
|
|
20
|
+
* // { label: "Recettes", href: "/fr/recipes" }
|
|
21
|
+
* // ]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function transformLangHrefs(items, lang) {
|
|
25
|
+
return items.map((item) => ({
|
|
26
|
+
...item,
|
|
27
|
+
href: item.href ? langHref(item.href, lang) : undefined,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Transforme un seul élément avec un href
|
|
32
|
+
* @param item - Élément contenant un champ href
|
|
33
|
+
* @param lang - Code de langue
|
|
34
|
+
* @returns L'élément avec le href transformé
|
|
35
|
+
*/
|
|
36
|
+
export function transformLangHref(item, lang) {
|
|
37
|
+
return {
|
|
38
|
+
...item,
|
|
39
|
+
href: item.href ? langHref(item.href, lang) : undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper pour créer une fonction de traduction côté serveur
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```tsx
|
|
6
|
+
* export default async function MyPage({ params }) {
|
|
7
|
+
* const t = await createServerTranslator(params);
|
|
8
|
+
* return <h1>{t("module-auth.welcome")}</h1>;
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function createServerTranslator(params: Promise<{
|
|
13
|
+
lang?: string;
|
|
14
|
+
}> | {
|
|
15
|
+
lang?: string;
|
|
16
|
+
}): Promise<(key: string) => string>;
|
|
17
|
+
/**
|
|
18
|
+
* Hook pour utiliser les traductions côté serveur avec namespace
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* export default async function MyPage({ params }) {
|
|
23
|
+
* const t = await createNamespacedTranslator(params, "module-auth");
|
|
24
|
+
* return <h1>{t("welcome")}</h1>; // Cherche "module-auth.welcome"
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createNamespacedTranslator(params: Promise<{
|
|
29
|
+
lang?: string;
|
|
30
|
+
}> | {
|
|
31
|
+
lang?: string;
|
|
32
|
+
}, namespace: string): Promise<(key: string) => string>;
|
|
33
|
+
//# sourceMappingURL=server-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-helpers.d.ts","sourceRoot":"","sources":["../../src/i18n/server-helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,CASlC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACtD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,CAOlC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { loadTranslations } from "./server-lang";
|
|
2
|
+
/**
|
|
3
|
+
* Helper pour créer une fonction de traduction côté serveur
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* export default async function MyPage({ params }) {
|
|
8
|
+
* const t = await createServerTranslator(params);
|
|
9
|
+
* return <h1>{t("module-auth.welcome")}</h1>;
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export async function createServerTranslator(params) {
|
|
14
|
+
// Si params est une Promise, l'attendre
|
|
15
|
+
const resolvedParams = params instanceof Promise ? await params : params;
|
|
16
|
+
const lang = resolvedParams.lang || "fr";
|
|
17
|
+
const translations = await loadTranslations(lang);
|
|
18
|
+
return (key) => {
|
|
19
|
+
return translations[key] || key;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Hook pour utiliser les traductions côté serveur avec namespace
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* export default async function MyPage({ params }) {
|
|
28
|
+
* const t = await createNamespacedTranslator(params, "module-auth");
|
|
29
|
+
* return <h1>{t("welcome")}</h1>; // Cherche "module-auth.welcome"
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export async function createNamespacedTranslator(params, namespace) {
|
|
34
|
+
const t = await createServerTranslator(params);
|
|
35
|
+
return (key) => {
|
|
36
|
+
const fullKey = `${namespace}.${key}`;
|
|
37
|
+
return t(fullKey);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Language = "fr" | "en";
|
|
2
|
+
/**
|
|
3
|
+
* Récupère la langue depuis les cookies côté serveur
|
|
4
|
+
*/
|
|
5
|
+
export declare function getServerLanguage(): Promise<Language>;
|
|
6
|
+
/**
|
|
7
|
+
* Charge les traductions pour une langue donnée côté serveur
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadTranslations(lang: Language): Promise<Record<string, string>>;
|
|
10
|
+
//# sourceMappingURL=server-lang.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-lang.d.ts","sourceRoot":"","sources":["../../src/i18n/server-lang.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAC,CAI3D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA8BjC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { cookies } from "next/headers";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Récupère la langue depuis les cookies côté serveur
|
|
6
|
+
*/
|
|
7
|
+
export async function getServerLanguage() {
|
|
8
|
+
const cookieStore = await cookies();
|
|
9
|
+
const lang = cookieStore.get("NEXT_LOCALE")?.value;
|
|
10
|
+
return lang || "fr";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Charge les traductions pour une langue donnée côté serveur
|
|
14
|
+
*/
|
|
15
|
+
export async function loadTranslations(lang) {
|
|
16
|
+
try {
|
|
17
|
+
// Charger depuis l'app final (source unique = concaténation de tous les modules)
|
|
18
|
+
// En développement et production, chercher dans apps/recipe/i18n (ou apps/lastbrain/i18n)
|
|
19
|
+
const appPaths = [
|
|
20
|
+
path.join(process.cwd(), "apps", "recipe", "i18n", `${lang}.json`),
|
|
21
|
+
path.join(process.cwd(), "apps", "lastbrain", "i18n", `${lang}.json`),
|
|
22
|
+
path.join(process.cwd(), "i18n", `${lang}.json`),
|
|
23
|
+
path.join("/app", "i18n", `${lang}.json`),
|
|
24
|
+
];
|
|
25
|
+
let translationPath = "";
|
|
26
|
+
for (const appPath of appPaths) {
|
|
27
|
+
if (fs.existsSync(appPath)) {
|
|
28
|
+
translationPath = appPath;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!fs.existsSync(translationPath)) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
const content = fs.readFileSync(translationPath, "utf-8");
|
|
36
|
+
const parsed = JSON.parse(content);
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
catch (_error) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only exports for i18n
|
|
3
|
+
*
|
|
4
|
+
* Import from "@lastbrain/app/i18n/server-lang" in Server Components
|
|
5
|
+
* Ne pas importer depuis "@lastbrain/app" pour éviter les erreurs côté client
|
|
6
|
+
*/
|
|
7
|
+
export { getServerLanguage, loadTranslations } from "./server-lang";
|
|
8
|
+
export { createServerTranslator, createNamespacedTranslator, } from "./server-helpers";
|
|
9
|
+
export type { Language } from "./LanguageProvider";
|
|
10
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/i18n/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only exports for i18n
|
|
3
|
+
*
|
|
4
|
+
* Import from "@lastbrain/app/i18n/server-lang" in Server Components
|
|
5
|
+
* Ne pas importer depuis "@lastbrain/app" pour éviter les erreurs côté client
|
|
6
|
+
*/
|
|
7
|
+
export { getServerLanguage, loadTranslations } from "./server-lang";
|
|
8
|
+
export { createServerTranslator, createNamespacedTranslator, } from "./server-helpers";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types pour le système i18n
|
|
3
|
+
*/
|
|
4
|
+
export type Language = "fr" | "en";
|
|
5
|
+
export type TranslationKey = string;
|
|
6
|
+
export interface Translations {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
export interface I18nConfig {
|
|
10
|
+
defaultLocale: Language;
|
|
11
|
+
locales: Language[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type pour les paramètres de page avec langue
|
|
15
|
+
*/
|
|
16
|
+
export interface LangParams {
|
|
17
|
+
params: Promise<{
|
|
18
|
+
lang: Language;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type pour les paramètres de page avec langue et ID
|
|
23
|
+
*/
|
|
24
|
+
export interface LangIdParams {
|
|
25
|
+
params: Promise<{
|
|
26
|
+
lang: Language;
|
|
27
|
+
id: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Helper type pour extraire les clés de traduction d'un module
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* type AuthTranslations = ModuleTranslations<"module-auth">;
|
|
35
|
+
* // "module-auth.welcome" | "module-auth.signin" | ...
|
|
36
|
+
*/
|
|
37
|
+
export type ModuleTranslations<T extends string> = `${T}.${string}`;
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,QAAQ,CAAC;IACxB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper autour de router.push/replace avec injection automatique du préfixe [lang].
|
|
3
|
+
*/
|
|
4
|
+
export declare function useLangRouter(): {
|
|
5
|
+
push: (href: string) => void;
|
|
6
|
+
replace: (href: string) => void;
|
|
7
|
+
prefetch: (href: string) => void;
|
|
8
|
+
back: () => void;
|
|
9
|
+
forward: () => void;
|
|
10
|
+
refresh: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useLangRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLangRouter.d.ts","sourceRoot":"","sources":["../../src/i18n/useLangRouter.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,aAAa;iBAKZ,MAAM;oBACH,MAAM;qBACL,MAAM;;;;EAK1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLocalizedRouter } from "@lastbrain/core";
|
|
3
|
+
import { useLink } from "./useLink";
|
|
4
|
+
/**
|
|
5
|
+
* Wrapper autour de router.push/replace avec injection automatique du préfixe [lang].
|
|
6
|
+
*/
|
|
7
|
+
export function useLangRouter() {
|
|
8
|
+
const router = useLocalizedRouter();
|
|
9
|
+
const link = useLink();
|
|
10
|
+
return {
|
|
11
|
+
push: (href) => router.push(link(href)),
|
|
12
|
+
replace: (href) => router.replace(link(href)),
|
|
13
|
+
prefetch: (href) => router.prefetch(link(href)),
|
|
14
|
+
back: () => router.back(),
|
|
15
|
+
forward: () => router.forward(),
|
|
16
|
+
refresh: () => router.refresh(),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Language } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Helper pour transformer un URL avec le paramètre [lang]
|
|
4
|
+
* Utile pour les transformations statiques avant le rendu React
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const href = langHref("/settings", "fr"); // "/fr/settings"
|
|
9
|
+
* const href = langHref("/api/users", "en"); // "/api/users" (API non modifiée)
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function langHref(href: string, lang: Language): string;
|
|
13
|
+
/**
|
|
14
|
+
* Hook pour générer des URLs avec le paramètre [lang] injecté automatiquement
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* "use client";
|
|
19
|
+
* import { useLink } from "@lastbrain/app";
|
|
20
|
+
*
|
|
21
|
+
* export function MyComponent() {
|
|
22
|
+
* const link = useLink();
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <>
|
|
26
|
+
* <img src={link("/api/storage/avatar.jpg")} />
|
|
27
|
+
* <a href={link("/recipes")}>Recettes</a>
|
|
28
|
+
* </>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useLink(): (href: string) => string;
|
|
34
|
+
//# sourceMappingURL=useLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../../src/i18n/useLink.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAgB7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,KAGb,MAAM,MAAM,KAAG,MAAM,CAG9B"}
|