Skip to content

Commit

Permalink
chore: passage tous les textes côté front sur i18nifty
Browse files Browse the repository at this point in the history
TODO: prévoir nettoyage des textes non-utilisés côté symfony
  • Loading branch information
ocruze committed Jan 18, 2025
1 parent 9606ce7 commit 55e3a9f
Show file tree
Hide file tree
Showing 42 changed files with 636 additions and 272 deletions.
3 changes: 1 addition & 2 deletions assets/components/Input/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MDEditor from "@uiw/react-md-editor";
import { CSSProperties, FC } from "react";

import getLocaleCommands from "../../modules/react-md/react-md-commands";
import Translator from "../../modules/Translator";

type MarkdownEditorProps = {
label?: string;
Expand Down Expand Up @@ -42,7 +41,7 @@ const MarkdownEditor: FC<MarkdownEditorProps> = (props) => {
commands={getLocaleCommands("fr")}
extraCommands={[]}
textareaProps={{
placeholder: placeholder ?? Translator.trans("service.wfs.new.description_form.markdown_placeholder"),
placeholder: placeholder,
}}
onChange={(newValue = "") => onChange(newValue)}
style={customStyle}
Expand Down
5 changes: 3 additions & 2 deletions assets/components/Layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { defaultNavItems } from "../../config/navItems/navItems";
import api from "../../entrepot/api";
import useDocumentTitle from "../../hooks/useDocumentTitle";
import { useTranslation } from "../../i18n/i18n";
import Translator from "../../modules/Translator";
import RQKeys from "../../modules/entrepot/RQKeys";
import getBreadcrumb from "../../modules/entrepot/breadcrumbs/Breadcrumb";
import { useRoute } from "../../router/router";
Expand All @@ -21,6 +20,8 @@ import AppFooter from "./AppFooter";
import AppHeader from "./AppHeader";

const HiddenElements: FC = () => {
const { t } = useTranslation("Common");

return (
<>
{/* doit être le premier élément du DOM (Accessibilité) : https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/gestionnaire-de-consentement */}
Expand All @@ -30,7 +31,7 @@ const HiddenElements: FC = () => {
links={[
{
anchor: "#main",
label: Translator.trans("site.go_to_content"),
label: t("go_to_content"),
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { declareComponentKeys } from "i18nifty";
import { Translations } from "../../../../i18n/types";

const { i18n } = declareComponentKeys<
| "title"
| { K: "community_technical_name"; P: { name?: string }; R: string }
| "join"
| { K: "modal.title"; P: { name?: string }; R: string }
| "modal.message"
| { K: "success_message.title"; P: { name?: string }; R: string }
| "success_message.description"
>()("CommunityList");
export type I18n = typeof i18n;

export const CommunityListFrTranslations: Translations<"fr">["CommunityList"] = {
title: "Rejoindre un espace de travail existant",
community_technical_name: ({ name }) => `Nom technique : ${name}`,
join: "Rejoindre",
"modal.title": ({ name }) => `Votre demande à rejoindre ${name} a été envoyée.`,
"modal.message": "Message (optionnel)",
"success_message.title": ({ name }) => `Votre demande à rejoindre ${name} a été envoyée.`,
"success_message.description": "Un accusé-réception vous a également été adressé.",
};

export const CommunityListEnTranslations: Translations<"en">["CommunityList"] = {
title: undefined,
community_technical_name: undefined,
join: undefined,
"modal.title": undefined,
"modal.message": undefined,
"success_message.title": undefined,
"success_message.description": undefined,
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { FC, useMemo, useRef, useState } from "react";
import { createPortal } from "react-dom";

import api from "../../api";
import AppLayout from "../../../components/Layout/AppLayout";
import LoadingText from "../../../components/Utils/LoadingText";
import Wait from "../../../components/Utils/Wait";
import { datastoreNavItems } from "../../../config/navItems/datastoreNavItems";
import RQKeys from "../../../modules/entrepot/RQKeys";
import Translator from "../../../modules/Translator";
import { CartesApiException } from "../../../modules/jsonFetch";
import { useAuthStore } from "../../../stores/AuthStore";
import { CommunityListResponseDto } from "../../../@types/entrepot";
import { regex, removeDiacritics } from "../../../utils";

import "../../../sass/pages/community_list.scss";
import { CommunityListResponseDto } from "../../../../@types/entrepot";
import AppLayout from "../../../../components/Layout/AppLayout";
import LoadingText from "../../../../components/Utils/LoadingText";
import Wait from "../../../../components/Utils/Wait";
import { datastoreNavItems } from "../../../../config/navItems/datastoreNavItems";
import { useTranslation } from "../../../../i18n";
import RQKeys from "../../../../modules/entrepot/RQKeys";
import { CartesApiException } from "../../../../modules/jsonFetch";
import { useAuthStore } from "../../../../stores/AuthStore";
import { regex, removeDiacritics } from "../../../../utils";
import api from "../../../api";

import "../../../../sass/pages/community_list.scss";

const joinCommunityModal = createModal({
id: "join-community-modal",
Expand All @@ -30,6 +30,8 @@ const joinCommunityModal = createModal({
const navItems = datastoreNavItems();

const CommunityList: FC = () => {
const { t } = useTranslation("CommunityList");
const { t: tCommon } = useTranslation("Common");
const { user } = useAuthStore();

const [searchText, setSearchText] = useState<string>();
Expand Down Expand Up @@ -86,8 +88,8 @@ const CommunityList: FC = () => {
};

return (
<AppLayout navItems={navItems} documentTitle={Translator.trans("communities_list.title")}>
<h1>{Translator.trans("communities_list.title")}</h1>
<AppLayout navItems={navItems} documentTitle={t("title")}>
<h1>{t("title")}</h1>

<div className={fr.cx("fr-container", "fr-py-2w")}>
{communitiesQuery.isLoading ? (
Expand All @@ -102,8 +104,8 @@ const CommunityList: FC = () => {
<Alert
severity="success"
closable
title={Translator.trans("communities_list.success_message_title", { name: selectedCommunity?.name })}
description={Translator.trans("communities_list.success_message_description")}
title={t("success_message.title", { name: selectedCommunity?.name })}
description={t("success_message.description")}
/>
)}

Expand Down Expand Up @@ -131,7 +133,7 @@ const CommunityList: FC = () => {
data={filteredCommunities.map((community) => [
community.name,
<Button key={community._id} size="small" onClick={() => handleClick(community)} priority="secondary">
{Translator.trans("communities_list.join")}
{t("join")}
</Button>,
])}
noCaption
Expand Down Expand Up @@ -162,22 +164,22 @@ const CommunityList: FC = () => {
<>
{createPortal(
<joinCommunityModal.Component
title={Translator.trans("communities_list.modal.title", { name: selectedCommunity?.name })}
title={t("modal.title", { name: selectedCommunity?.name })}
buttons={[
{
children: Translator.trans("commons.cancel"),
children: tCommon("cancel"),
doClosesModal: true,
priority: "secondary",
},
{
children: Translator.trans("send"),
children: tCommon("send"),
onClick: handleOk,
doClosesModal: true,
priority: "primary",
},
]}
>
<Input nativeTextAreaProps={{ ref: refMsg }} label={Translator.trans("communities_list.modal.message")} textArea />
<Input nativeTextAreaProps={{ ref: refMsg }} label={t("modal.message")} textArea />
</joinCommunityModal.Component>,
document.body
)}
Expand Down
8 changes: 7 additions & 1 deletion assets/entrepot/pages/dashboard/DashboardPro.locale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import { declareComponentKeys } from "i18nifty";

import { Translations } from "../../../i18n/types";

const { i18n } = declareComponentKeys<"document_title" | "espaceco_frontoffice_list" | "datastore_for_tests">()("DashboardPro");
const { i18n } = declareComponentKeys<
"document_title" | "espaceco_frontoffice_list" | "datastore_for_tests" | "datastore_creation_form" | "join_existing_community"
>()("DashboardPro");
export type I18n = typeof i18n;

export const DashboardProFrTranslations: Translations<"fr">["DashboardPro"] = {
document_title: "Tableau de bord professionnel",
espaceco_frontoffice_list: "Liste des guichets de l’espace collaboratif",
datastore_for_tests: "À des fins de test",
datastore_creation_form: "Demande de création d’un espace de travail",
join_existing_community: "Rejoindre un espace de travail existant",
};

export const DashboardProEnTranslations: Translations<"en">["DashboardPro"] = {
document_title: "Professional dashboard",
espaceco_frontoffice_list: "List of collaborative space front offices",
datastore_for_tests: "For testing purposes",
datastore_creation_form: undefined,
join_existing_community: undefined,
};
7 changes: 4 additions & 3 deletions assets/entrepot/pages/dashboard/DashboardPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import LoadingIcon from "../../../components/Utils/LoadingIcon";
import Skeleton from "../../../components/Utils/Skeleton";
import { datastoreNavItems } from "../../../config/navItems/datastoreNavItems";
import { useTranslation } from "../../../i18n/i18n";
import Translator from "../../../modules/Translator";
import RQKeys from "../../../modules/entrepot/RQKeys";
import { CartesApiException } from "../../../modules/jsonFetch";
import { routes } from "../../../router/router";
Expand Down Expand Up @@ -166,18 +165,20 @@ const DashboardPro = () => {
<Tile
linkProps={routes.datastore_create_request().link}
imageUrl={mailSendSvgUrl}
imageSvg={true}
desc="Contacter le support pour créer un nouvel espace de travail"
orientation="horizontal"
title={Translator.trans("datastore_creation_request.title")}
title={t("datastore_creation_form")}
/>
</div>
<div className={fr.cx("fr-col-12", "fr-col-sm-6")}>
<Tile
linkProps={routes.join_community().link}
imageUrl={humanCoopSvgUrl}
imageSvg={true}
desc="Demander à rejoindre une communauté publique"
orientation="horizontal"
title={Translator.trans("communities_list.title")}
title={t("join_existing_community")}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { declareComponentKeys } from "i18nifty";
import { Translations } from "../../../../i18n/types";
import { Translations } from "../../../../../i18n/types";

const { i18n } = declareComponentKeys<
| { K: "title"; P: { datasheetName: string | undefined }; R: string }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import { symToStr } from "tsafe/symToStr";
import { v4 as uuidv4 } from "uuid";
import * as yup from "yup";

import DatastoreLayout from "../../../../components/Layout/DatastoreLayout";
import LoadingIcon from "../../../../components/Utils/LoadingIcon";
import LoadingText from "../../../../components/Utils/LoadingText";
import Progress from "../../../../components/Utils/Progress";
import Wait from "../../../../components/Utils/Wait";
import defaultProjections from "../../../../data/default_projections.json";
import ignfProjections from "../../../../data/ignf_projections.json";
import { useTranslation } from "../../../../i18n/i18n";
import FileUploader from "../../../../modules/FileUploader";
import RQKeys from "../../../../modules/entrepot/RQKeys";
import { routes, useRoute } from "../../../../router/router";
import { getFileExtension, regex } from "../../../../utils";
import api from "../../../api";
import DatasheetUploadIntegrationDialog from "./DatasheetUploadIntegration/DatasheetUploadIntegrationDialog";
import DatastoreLayout from "../../../../../components/Layout/DatastoreLayout";
import LoadingIcon from "../../../../../components/Utils/LoadingIcon";
import LoadingText from "../../../../../components/Utils/LoadingText";
import Progress from "../../../../../components/Utils/Progress";
import Wait from "../../../../../components/Utils/Wait";
import defaultProjections from "../../../../../data/default_projections.json";
import ignfProjections from "../../../../../data/ignf_projections.json";
import { useTranslation } from "../../../../../i18n/i18n";
import FileUploader from "../../../../../modules/FileUploader";
import RQKeys from "../../../../../modules/entrepot/RQKeys";
import { routes, useRoute } from "../../../../../router/router";
import { getFileExtension, regex } from "../../../../../utils";
import api from "../../../../api";
import DatasheetUploadIntegrationDialog from "../DatasheetUploadIntegration/DatasheetUploadIntegrationDialog";

const maxFileSize = 2000000000; // 2 GB
const fileExtensions = ["gpkg", "zip"];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { declareComponentKeys } from "i18nifty";
import { Translations } from "../../../../../i18n/types";

const { i18n } = declareComponentKeys<
| { K: "step_title"; P: { step_name: string }; R: string }
| { K: "step_status_text"; P: { step_status: string }; R: string }
| "data_integration_in_progress"
| "long_operation_information"
| "continue_browsing_data_not_ready"
| "view_datasheet"
| "check_error_report"
| "back_to_datasheet_list"
| "integration_page.title"
>()("DatasheetUploadIntegration");
export type I18n = typeof i18n;

export const DatasheetUploadIntegrationFrTranslations: Translations<"fr">["DatasheetUploadIntegration"] = {
step_title: ({ step_name }) => {
switch (step_name) {
case "send_files_api":
return "Chargement des fichiers";
case "wait_checks":
return "Vérifications standard et vecteur";
case "integration_processing":
return "Intégration en base de données";
default:
return "Étape inconnue";
}
},
step_status_text: ({ step_status }) => {
switch (step_status) {
case "in_progress":
return "En cours";
case "successful":
return "Succès";
case "failed":
return "Echec";
case "waiting":
return "En attente";
default:
return "Statut inconnu";
}
},
data_integration_in_progress: "Vos données vecteur sont en cours de dépôt",
long_operation_information: "Les opérations suivantes peuvent prendre quelques minutes. Merci pour votre patience.",
continue_browsing_data_not_ready: "Vous pouvez maintenant poursuivre votre navigation même si vos données ne sont pas encore prêtes.",
view_datasheet: "Consulter la fiche de données",
check_error_report: "Voir le rapport d’erreur",
back_to_datasheet_list: "Revenir à mes données",

"integration_page.title": "Intégration des données",
};

export const DatasheetUploadIntegrationEnTranslations: Translations<"en">["DatasheetUploadIntegration"] = {
step_title: undefined,
step_status_text: undefined,
data_integration_in_progress: undefined,
long_operation_information: undefined,
continue_browsing_data_not_ready: undefined,
view_datasheet: undefined,
check_error_report: undefined,
back_to_datasheet_list: undefined,

"integration_page.title": undefined,
};
Loading

0 comments on commit 55e3a9f

Please sign in to comment.