2022-06-15 00:29:06 +02:00
|
|
|
import './index.css';
|
|
|
|
|
2020-12-10 22:58:46 +01:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2020-12-31 17:38:30 +01:00
|
|
|
import { IntlProvider } from 'react-intl';
|
|
|
|
|
2020-12-10 22:58:46 +01:00
|
|
|
import App from './App';
|
2022-06-15 00:29:06 +02:00
|
|
|
import messages from './messages';
|
2020-12-10 22:58:46 +01:00
|
|
|
import reportWebVitals from './reportWebVitals';
|
2020-12-31 17:38:30 +01:00
|
|
|
|
|
|
|
|
2022-06-15 00:29:06 +02:00
|
|
|
const GLOBAL_MESSAGE_KEY = "global";
|
2020-12-31 17:38:30 +01:00
|
|
|
const i18nConfig = {
|
2022-06-15 00:29:06 +02:00
|
|
|
defaultLocale: 'fr',
|
|
|
|
messages,
|
2020-12-31 17:38:30 +01:00
|
|
|
};
|
|
|
|
|
2022-06-15 00:29:06 +02:00
|
|
|
const language = function () {
|
2020-12-31 17:38:30 +01:00
|
|
|
const queryString = window.location.search;
|
|
|
|
const urlParams = new URLSearchParams(queryString);
|
|
|
|
let lang = urlParams.get("lang");
|
2022-06-15 00:29:06 +02:00
|
|
|
if (messages[lang] === undefined) {
|
2020-12-31 17:38:30 +01:00
|
|
|
lang = navigator.language.split(/[-_]/)[0];
|
|
|
|
}
|
|
|
|
return lang;
|
|
|
|
}
|
2020-12-10 22:58:46 +01:00
|
|
|
|
2022-06-15 00:29:06 +02:00
|
|
|
const langJson = function () {
|
|
|
|
const messageLocalized = i18nConfig.messages[language()];
|
|
|
|
const messageGlobal = i18nConfig.messages[GLOBAL_MESSAGE_KEY];
|
|
|
|
const messageMerged = {
|
|
|
|
...messageLocalized,
|
|
|
|
...messageGlobal
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log(JSON.stringify(messageMerged))
|
|
|
|
return messageMerged;
|
|
|
|
}
|
|
|
|
|
2020-12-10 22:58:46 +01:00
|
|
|
ReactDOM.render(
|
|
|
|
<React.StrictMode>
|
2022-06-15 00:29:06 +02:00
|
|
|
<IntlProvider
|
2020-12-31 17:38:30 +01:00
|
|
|
locale={language}
|
|
|
|
defaultLocale={i18nConfig.defaultLocale}
|
2022-06-15 00:29:06 +02:00
|
|
|
messages={langJson()}
|
2020-12-31 17:38:30 +01:00
|
|
|
>
|
2022-06-15 00:29:06 +02:00
|
|
|
<App />
|
2020-12-31 17:38:30 +01:00
|
|
|
</IntlProvider>
|
2020-12-10 22:58:46 +01:00
|
|
|
</React.StrictMode>,
|
|
|
|
document.getElementById('root')
|
|
|
|
);
|
|
|
|
|
|
|
|
// If you want to start measuring performance in your app, pass a function
|
|
|
|
// to log results (for example: reportWebVitals(console.log))
|
|
|
|
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
|
|
reportWebVitals();
|