From d24d6de8ba1645afd779301d8331ee464d079278 Mon Sep 17 00:00:00 2001 From: horacioskrp Date: Fri, 13 Nov 2026 13:46:09 +0000 Subject: [PATCH] =?UTF-8?q?feat(i18n):=20composants=20partag=C3=A9s=20?= =?UTF-8?q?=E2=80=94=20=C3=A9diteur=20de=20texte=20riche=20&=20illustratio?= =?UTF-8?q?ns=20d'erreur=20(FR/EN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/en/common.php | 13 ++++++ lang/fr/common.php | 13 ++++++ resources/js/components/error-art.tsx | 45 +++++++++++--------- resources/js/components/rich-text-editor.tsx | 25 ++++++----- 4 files changed, 64 insertions(+), 32 deletions(-) diff --git a/lang/en/common.php b/lang/en/common.php index 21ccb6c6..50847749 100644 --- a/lang/en/common.php +++ b/lang/en/common.php @@ -44,4 +44,17 @@ 'per_page' => 'Rows per page', 'page' => 'Page', ], + 'editor' => [ + 'bold' => 'Bold', + 'italic' => 'Italic', + 'heading1' => 'Heading 1', + 'heading2' => 'Heading 2', + 'bullet_list' => 'Bulleted list', + 'numbered_list' => 'Numbered list', + 'align_left' => 'Align left', + 'align_center' => 'Center', + 'align_right' => 'Align right', + 'undo' => 'Undo', + 'redo' => 'Redo', + ], ]; diff --git a/lang/fr/common.php b/lang/fr/common.php index 9de57286..7e230654 100644 --- a/lang/fr/common.php +++ b/lang/fr/common.php @@ -44,4 +44,17 @@ 'per_page' => 'Lignes par page', 'page' => 'Page', ], + 'editor' => [ + 'bold' => 'Gras', + 'italic' => 'Italique', + 'heading1' => 'Titre 1', + 'heading2' => 'Titre 2', + 'bullet_list' => 'Liste à puces', + 'numbered_list' => 'Liste numérotée', + 'align_left' => 'Aligner à gauche', + 'align_center' => 'Centrer', + 'align_right' => 'Aligner à droite', + 'undo' => 'Annuler', + 'redo' => 'Rétablir', + ], ]; diff --git a/resources/js/components/error-art.tsx b/resources/js/components/error-art.tsx index 037d8371..3633c091 100644 --- a/resources/js/components/error-art.tsx +++ b/resources/js/components/error-art.tsx @@ -3,11 +3,13 @@ * utilitaires Tailwind fill et stroke). Une illustration par statut HTTP. */ +import { useTranslation } from '@/helpers/i18n'; + const wrap = 'w-full max-w-[240px] mx-auto h-auto'; -function NotFound() { +function NotFound({ label }: Readonly<{ label: string }>) { return ( - + @@ -17,9 +19,9 @@ function NotFound() { ); } -function Forbidden() { +function Forbidden({ label }: Readonly<{ label: string }>) { return ( - + @@ -30,9 +32,9 @@ function Forbidden() { ); } -function Expired() { +function Expired({ label }: Readonly<{ label: string }>) { return ( - + @@ -43,9 +45,9 @@ function Expired() { ); } -function TooMany() { +function TooMany({ label }: Readonly<{ label: string }>) { return ( - + @@ -56,9 +58,9 @@ function TooMany() { ); } -function ServerError() { +function ServerError({ label }: Readonly<{ label: string }>) { return ( - + @@ -74,9 +76,9 @@ function ServerError() { ); } -function Maintenance() { +function Maintenance({ label }: Readonly<{ label: string }>) { return ( - + @@ -90,9 +92,9 @@ function Maintenance() { ); } -function Generic() { +function Generic({ label }: Readonly<{ label: string }>) { return ( - + @@ -103,13 +105,14 @@ function Generic() { } export function ErrorArt({ status }: Readonly<{ status: number }>) { + const { t } = useTranslation(); switch (status) { - case 403: return ; - case 404: return ; - case 419: return ; - case 429: return ; - case 500: return ; - case 503: return ; - default: return ; + case 403: return ; + case 404: return ; + case 419: return ; + case 429: return ; + case 500: return ; + case 503: return ; + default: return ; } } diff --git a/resources/js/components/rich-text-editor.tsx b/resources/js/components/rich-text-editor.tsx index 9e39aaaf..02d0eb87 100644 --- a/resources/js/components/rich-text-editor.tsx +++ b/resources/js/components/rich-text-editor.tsx @@ -6,6 +6,7 @@ import { Italic, List, ListOrdered, Redo, Undo, } from 'lucide-react'; import { useEffect } from 'react'; +import { useTranslation } from '@/helpers/i18n'; interface Props { value: string; @@ -32,6 +33,8 @@ export function RichTextEditor({ value, onChange, onReady }: Readonly) { // cette directive désactive sa mémoïsation pour ce composant. 'use no memo'; + const { t } = useTranslation(); + const editor = useEditor({ extensions: [ StarterKit, @@ -65,21 +68,21 @@ export function RichTextEditor({ value, onChange, onReady }: Readonly) { return (
- editor.chain().focus().toggleBold().run()}> - editor.chain().focus().toggleItalic().run()}> + editor.chain().focus().toggleBold().run()}> + editor.chain().focus().toggleItalic().run()}>
- editor.chain().focus().toggleHeading({ level: 1 }).run()}> - editor.chain().focus().toggleHeading({ level: 2 }).run()}> + editor.chain().focus().toggleHeading({ level: 1 }).run()}> + editor.chain().focus().toggleHeading({ level: 2 }).run()}>
- editor.chain().focus().toggleBulletList().run()}> - editor.chain().focus().toggleOrderedList().run()}> + editor.chain().focus().toggleBulletList().run()}> + editor.chain().focus().toggleOrderedList().run()}>
- editor.chain().focus().setTextAlign('left').run()}> - editor.chain().focus().setTextAlign('center').run()}> - editor.chain().focus().setTextAlign('right').run()}> + editor.chain().focus().setTextAlign('left').run()}> + editor.chain().focus().setTextAlign('center').run()}> + editor.chain().focus().setTextAlign('right').run()}>
- editor.chain().focus().undo().run()}> - editor.chain().focus().redo().run()}> + editor.chain().focus().undo().run()}> + editor.chain().focus().redo().run()}>