-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
52 lines (46 loc) · 1.68 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* This file is part of ANA StanCal.
* See: <https://github.com/anairsoft/stancal>.
*
* Copyright (C) 2018 Association de Normalisation de l'Airsoft <[email protected]>.
* Copyright (C) 2018 Jérémy Walther <[email protected]>.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Otherwise, see: <https://www.gnu.org/licenses/gpl-3.0>.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import './index.css';
import { addLocaleData, IntlProvider } from 'react-intl';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
function getQueryParameter(name) {
return unescape(window.location.search
.replace(new RegExp("^(?:.*[&\\?]" + escape(name)
.replace(/[.+*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}
const locales = ['en', 'fr'];
const defaultLocale = 'en';
const queryLocale = getQueryParameter('locale');
const locale = queryLocale
|| (navigator.languages && navigator.languages[0])
|| navigator.language
|| navigator.userLanguage;
const localeShort = locale.toLowerCase().split(/[_-]+/)[0];
const messages = locales.includes(localeShort)
? require('./lang/' + localeShort)
: require('./lang/' + defaultLocale);
addLocaleData(locales.includes(localeShort)
? require('react-intl/locale-data/' + localeShort)
: require('react-intl/locale-data/' + defaultLocale));
ReactDOM.render(
<IntlProvider
locale={locale}
messages={messages}>
<App />
</IntlProvider>,
document.getElementById('root'));
registerServiceWorker();