make translations work
Change-Id: I36d35e6745b8955fe6c801963abd57267df85ac4
diff --git a/client/src/components/Message.js b/client/src/components/Message.js
index 9e6fcb7..a16edd8 100644
--- a/client/src/components/Message.js
+++ b/client/src/components/Message.js
@@ -3,6 +3,7 @@
import isToday from "dayjs/plugin/isToday"
import isYesterday from "dayjs/plugin/isYesterday"
import React from "react"
+import { useTranslation } from "react-i18next"
dayjs.extend(isToday)
dayjs.extend(isYesterday)
@@ -18,11 +19,12 @@
}
export const MessageInitial = (props) => {
+ const { t } = useTranslation()
return (
<Stack
alignItems="center"
>
- "Le Swarm a été créé"
+ {t("message_swarm_created")}
</Stack>
)
}
@@ -41,6 +43,7 @@
}
export const MessageMember = (props) => {
+ const { t } = useTranslation()
return (
<Stack
alignItems="center"
@@ -49,7 +52,7 @@
sx={{
width: "fit-content",
}}
- label={`${props.message.author} s'est joint`}
+ label={t("message_user_joined", {user: props.message.author})}
/>
</Stack>
)
diff --git a/client/src/i18n.js b/client/src/i18n.js
new file mode 100644
index 0000000..85e043f
--- /dev/null
+++ b/client/src/i18n.js
@@ -0,0 +1,24 @@
+import i18n from "i18next";
+import { initReactI18next } from "react-i18next";
+import translationEn from "../public/locale/en/translation.json"
+import translationFr from "../public/locale/fr/translation.json"
+
+i18n
+.use(initReactI18next)
+.init({
+ debug: process.env.NODE_ENV == "development",
+ lng: "en",
+ interpolation: {
+ escapeValue: false,
+ },
+ resources: {
+ en: {
+ translation: translationEn,
+ },
+ fr: {
+ translation: translationFr,
+ },
+ },
+});
+
+export default i18n;
diff --git a/client/src/index.js b/client/src/index.js
index e0bc61b..982f0f7 100644
--- a/client/src/index.js
+++ b/client/src/index.js
@@ -6,6 +6,7 @@
import { store } from "../redux/store";
import { Provider } from "react-redux";
import { BrowserRouter as Router } from "react-router-dom";
+import './i18n';
// import config from "../sentry-client.config.json"
import * as Sentry from "@sentry/react";