Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ dist-ssr
*.sln
*.sw?

METABASE_LOGIN.json
METABASE_LOGIN.json

# Translations
public/locales
2 changes: 2 additions & 0 deletions webapp/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"^@pages/(.*)$",
"^@ui",
"^@ui/(.*)$",
"^@shared",
"^@shared/(.*)$",
"[../]",
"[./]"
],
Expand Down
1 change: 1 addition & 0 deletions webapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ npm run dev
- `npm run preview` : Démarre le serveur à partir du build pour la production (dans le dist)
- `npm run check:arch` : Vérifier si les imports du projet respectent le principe de l'architecture FSD.
- `npm run arch:tree` : Génère un fichier text contenant l'arborescence du projet.
- `npm run translations:update`: Upload les fichiers de traductions vers public/locales, depuis lequel sont servis les fichiers de traduction
160 changes: 159 additions & 1 deletion webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"format": "prettier . --write",
"format:check": "prettier . --check",
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix"
"lint:fix": "eslint ./src --fix",
"translations:update": "./scripts/update-translations.sh"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.15",
Expand All @@ -30,10 +31,14 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"coordo": "github:dataforgoodfr/Coordonnees#master",
"i18next": "^25.8.0",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",
"lucide-react": "^0.562.0",
"react": "^19.2.0",
"react-chartjs-2": "^5.3.1",
"react-dom": "^19.2.0",
"react-i18next": "^16.5.4",
"react-resizable-panels": "^3.0.6",
"recharts": "^2.15.4"
},
Expand Down
5 changes: 5 additions & 0 deletions webapp/scripts/update-translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Copy src/shared/i18n/translations/{files} -> public/locales/{files}

cp -R ./src/shared/i18n/translations/ public/locales/
7 changes: 7 additions & 0 deletions webapp/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import logo from "@assets/logo_all4trees.png";

import { Button } from "@ui/button";

import { useTranslation } from "@shared/i18n";

import { LanguageSelecor } from "./LanguageSelector";
import { ModeToggle } from "./ModeToggle";

interface HeaderProps {
Expand All @@ -14,6 +17,8 @@ interface HeaderProps {
}

export function Header({ onLogout, onLogin, isLogin }: HeaderProps) {
const { t } = useTranslation("translations");

return (
<header className="bg-background border-b border-border px-6 py-4 relative z-40">
<div className="mx-auto max-w-screen-2xl px-6 py-4">
Expand Down Expand Up @@ -41,6 +46,8 @@ export function Header({ onLogout, onLogin, isLogin }: HeaderProps) {
</Button>
)}
<ModeToggle />
<p>{t("helloWorld")}</p>
<LanguageSelecor />
</div>
</div>
</div>
Expand Down
55 changes: 55 additions & 0 deletions webapp/src/components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { LanguagesIcon } from "lucide-react";
import type { FC } from "react";

import { Button } from "@ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@ui/dropdown-menu";

import { LANGUAGES, i18nInstance } from "@shared/i18n";

const LANGUAGES_CONFIGS = [
{
identifier: LANGUAGES.FRENCH,
fullString: "Français",
flag: "🇫🇷",
},
{
identifier: LANGUAGES.ENGLISH,
fullString: "English",
flag: "🇬🇧",
},
] as const;

export const LanguageSelecor: FC = () => {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="icon"
className="focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none"
>
<LanguagesIcon className="h-[1.2rem] w-[1.2rem]" />
<span className="sr-only">{i18nInstance.language.toUpperCase()}</span>
</Button>
</DropdownMenuTrigger>

<DropdownMenuContent
className="bg-background"
align="end"
>
{LANGUAGES_CONFIGS.map((config) => (
<DropdownMenuItem
onClick={() => i18nInstance.changeLanguage(config.identifier)}
>
{`${config.flag} - ${config.fullString}`}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
);
};
Loading
Loading