Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
feat(lang): internationalisation of header and navigation
Browse files
frontend/src/App.jsx
CHANGED
@@ -12,7 +12,7 @@ import LeaderboardPage from "./pages/LeaderboardPage/LeaderboardPage";
|
|
12 |
import AddModelPage from "./pages/AddModelPage/AddModelPage";
|
13 |
import QuotePage from "./pages/QuotePage/QuotePage";
|
14 |
import VoteModelPage from "./pages/VoteModelPage/VoteModelPage";
|
15 |
-
import
|
16 |
import { Badge } from "@codegouvfr/react-dsfr/Badge";
|
17 |
import Footer from "./components/Footer/Footer";
|
18 |
import MuiDsfrThemeProvider from "@codegouvfr/react-dsfr/mui";
|
@@ -93,22 +93,7 @@ function App() {
|
|
93 |
color: "text.primary",
|
94 |
}}
|
95 |
>
|
96 |
-
<Header
|
97 |
-
brandTop={<>République <br/> française</>}
|
98 |
-
homeLinkProps={{
|
99 |
-
href: '/',
|
100 |
-
title: 'Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)'
|
101 |
-
}}
|
102 |
-
quickAccessItems={[
|
103 |
-
// other quick access items...
|
104 |
-
headerFooterDisplayItem,
|
105 |
-
<LanguageSelect />
|
106 |
-
]}
|
107 |
-
id="fr-header-simple-header-with-service-title-and-tagline"
|
108 |
-
serviceTagline="Tableau de référence pour les grands modèles de langages en français"
|
109 |
-
serviceTitle={<>Leaderboard des GML pour le français{' '}<Badge as="span" noIcon severity="success">Beta</Badge></>}
|
110 |
-
navigation={<Navigation />}
|
111 |
-
/>
|
112 |
<Box
|
113 |
sx={{
|
114 |
flex: 1,
|
|
|
12 |
import AddModelPage from "./pages/AddModelPage/AddModelPage";
|
13 |
import QuotePage from "./pages/QuotePage/QuotePage";
|
14 |
import VoteModelPage from "./pages/VoteModelPage/VoteModelPage";
|
15 |
+
import Header from "./components/Header/Header";
|
16 |
import { Badge } from "@codegouvfr/react-dsfr/Badge";
|
17 |
import Footer from "./components/Footer/Footer";
|
18 |
import MuiDsfrThemeProvider from "@codegouvfr/react-dsfr/mui";
|
|
|
93 |
color: "text.primary",
|
94 |
}}
|
95 |
>
|
96 |
+
<Header />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
<Box
|
98 |
sx={{
|
99 |
flex: 1,
|
frontend/src/components/Header/Header.tsx
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Header } from "@codegouvfr/react-dsfr/Header";
|
2 |
+
import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display";
|
3 |
+
import { LanguageSelect } from "../LanguageSelect/LanguageSelect";
|
4 |
+
import Navigation from "../Navigation/Navigation";
|
5 |
+
import { Badge } from "@codegouvfr/react-dsfr/Badge";
|
6 |
+
import { useTranslation, declareComponentKeys } from "i18n";
|
7 |
+
|
8 |
+
const header = () => {
|
9 |
+
const {t} = useTranslation({header});
|
10 |
+
return <Header
|
11 |
+
brandTop={<>République <br/> française</>}
|
12 |
+
homeLinkProps={{
|
13 |
+
href: '/',
|
14 |
+
title: 'Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)'
|
15 |
+
}}
|
16 |
+
quickAccessItems={[
|
17 |
+
// other quick access items...
|
18 |
+
headerFooterDisplayItem,
|
19 |
+
<LanguageSelect />
|
20 |
+
]}
|
21 |
+
id="fr-header-simple-header-with-service-title-and-tagline"
|
22 |
+
serviceTagline={t("tagline")}
|
23 |
+
serviceTitle={<>{t("service")}{' '}<Badge as="span" noIcon severity="success">Beta</Badge></>}
|
24 |
+
navigation={<Navigation />}
|
25 |
+
/>
|
26 |
+
}
|
27 |
+
|
28 |
+
const { i18n } = declareComponentKeys<
|
29 |
+
| "tagline"
|
30 |
+
| "service"
|
31 |
+
>()({ header });
|
32 |
+
export type I18n = typeof i18n;
|
33 |
+
|
34 |
+
export default header;
|
frontend/src/components/Navigation/{Navigation.jsx → Navigation.tsx}
RENAMED
@@ -1,15 +1,17 @@
|
|
1 |
import React, { useState } from "react";
|
2 |
import { useLocation, useNavigate, useSearchParams } from "react-router-dom";
|
3 |
import {MainNavigation} from "@codegouvfr/react-dsfr/MainNavigation";
|
|
|
4 |
|
5 |
const Navigation = () => {
|
6 |
const location = useLocation();
|
7 |
const navigate = useNavigate();
|
8 |
const [active, setActive] = useState(0);
|
9 |
const [searchParams] = useSearchParams();
|
|
|
10 |
|
11 |
// Function to sync URL with parent HF page
|
12 |
-
const syncUrlWithParent = (queryString, hash) => {
|
13 |
// Check if we're in an HF Space iframe
|
14 |
const isHFSpace = window.location !== window.parent.location;
|
15 |
if (isHFSpace) {
|
@@ -29,7 +31,7 @@ const Navigation = () => {
|
|
29 |
}
|
30 |
};
|
31 |
|
32 |
-
const handleNavigation = (index, path) => (e) => {
|
33 |
e.preventDefault();
|
34 |
const searchString = searchParams.toString();
|
35 |
const queryString = searchString ? `?${searchString}` : "";
|
@@ -64,7 +66,7 @@ const Navigation = () => {
|
|
64 |
target: '_self',
|
65 |
onClick: handleNavigation(1, "/add")
|
66 |
},
|
67 |
-
text: "
|
68 |
},
|
69 |
// {
|
70 |
// isActive: active === 2,
|
@@ -204,4 +206,9 @@ const Navigation = () => {
|
|
204 |
// );
|
205 |
};
|
206 |
|
|
|
|
|
|
|
|
|
|
|
207 |
export default Navigation;
|
|
|
1 |
import React, { useState } from "react";
|
2 |
import { useLocation, useNavigate, useSearchParams } from "react-router-dom";
|
3 |
import {MainNavigation} from "@codegouvfr/react-dsfr/MainNavigation";
|
4 |
+
import { useTranslation, declareComponentKeys } from "i18n";
|
5 |
|
6 |
const Navigation = () => {
|
7 |
const location = useLocation();
|
8 |
const navigate = useNavigate();
|
9 |
const [active, setActive] = useState(0);
|
10 |
const [searchParams] = useSearchParams();
|
11 |
+
const {t} = useTranslation({Navigation});
|
12 |
|
13 |
// Function to sync URL with parent HF page
|
14 |
+
const syncUrlWithParent = (queryString: any, hash:any) => {
|
15 |
// Check if we're in an HF Space iframe
|
16 |
const isHFSpace = window.location !== window.parent.location;
|
17 |
if (isHFSpace) {
|
|
|
31 |
}
|
32 |
};
|
33 |
|
34 |
+
const handleNavigation = (index:any, path:any) => (e:any) => {
|
35 |
e.preventDefault();
|
36 |
const searchString = searchParams.toString();
|
37 |
const queryString = searchString ? `?${searchString}` : "";
|
|
|
66 |
target: '_self',
|
67 |
onClick: handleNavigation(1, "/add")
|
68 |
},
|
69 |
+
text: t("submit"),
|
70 |
},
|
71 |
// {
|
72 |
// isActive: active === 2,
|
|
|
206 |
// );
|
207 |
};
|
208 |
|
209 |
+
const { i18n } = declareComponentKeys<
|
210 |
+
| "submit"
|
211 |
+
>()({ Navigation });
|
212 |
+
export type I18n = typeof i18n;
|
213 |
+
|
214 |
export default Navigation;
|
frontend/src/i18n.tsx
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import { createI18nApi, declareComponentKeys } from "i18nifty";
|
|
|
2 |
|
3 |
//List the languages you with to support
|
4 |
export const languages = ["en", "fr"] as const;
|
@@ -12,7 +13,7 @@ export type Language = typeof languages[number];
|
|
12 |
export type LocalizedString = Parameters<typeof resolveLocalizedString>[0];
|
13 |
|
14 |
export const {
|
15 |
-
useTranslation,
|
16 |
resolveLocalizedString,
|
17 |
useLang,
|
18 |
$lang,
|
@@ -21,6 +22,8 @@ export const {
|
|
21 |
getTranslation,
|
22 |
} = createI18nApi<
|
23 |
| import ("pages/LeaderboardPage/LeaderboardPage").I18n
|
|
|
|
|
24 |
>()(
|
25 |
{
|
26 |
languages,
|
@@ -38,6 +41,13 @@ export const {
|
|
38 |
</>
|
39 |
)
|
40 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
},
|
42 |
/* spell-checker: disable */
|
43 |
"fr": {
|
@@ -51,6 +61,13 @@ export const {
|
|
51 |
</>
|
52 |
)
|
53 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
/* spell-checker: enable */
|
56 |
}
|
|
|
1 |
import { createI18nApi, declareComponentKeys } from "i18nifty";
|
2 |
+
export {declareComponentKeys};
|
3 |
|
4 |
//List the languages you with to support
|
5 |
export const languages = ["en", "fr"] as const;
|
|
|
13 |
export type LocalizedString = Parameters<typeof resolveLocalizedString>[0];
|
14 |
|
15 |
export const {
|
16 |
+
useTranslation,
|
17 |
resolveLocalizedString,
|
18 |
useLang,
|
19 |
$lang,
|
|
|
22 |
getTranslation,
|
23 |
} = createI18nApi<
|
24 |
| import ("pages/LeaderboardPage/LeaderboardPage").I18n
|
25 |
+
| import ("components/Header/Header").I18n
|
26 |
+
| import ("components/Navigation/Navigation").I18n
|
27 |
>()(
|
28 |
{
|
29 |
languages,
|
|
|
41 |
</>
|
42 |
)
|
43 |
},
|
44 |
+
"header": {
|
45 |
+
"tagline": "Reference table for large language models in french",
|
46 |
+
"service": "LLM leaderboard for the french language"
|
47 |
+
},
|
48 |
+
"Navigation": {
|
49 |
+
"submit": "Submit"
|
50 |
+
}
|
51 |
},
|
52 |
/* spell-checker: disable */
|
53 |
"fr": {
|
|
|
61 |
</>
|
62 |
)
|
63 |
},
|
64 |
+
"header": {
|
65 |
+
"tagline": "Tableau de référence pour les grands modèles de langages en français",
|
66 |
+
"service": "Leaderboard des GML pour le français"
|
67 |
+
},
|
68 |
+
"Navigation": {
|
69 |
+
"submit": "Soumettre"
|
70 |
+
}
|
71 |
}
|
72 |
/* spell-checker: enable */
|
73 |
}
|