Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed language detection issues

Blue Mouse72d0ab82e5e5
diff --git a/src/api/index.js b/src/api/index.js
index 3e3e5d337..57275a883 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -221,7 +221,7 @@ export const getProjectData = (
tb = 'hour',
period = '3d',
from = '',
- to = ''
+ to = '',
) =>
api
.get(
diff --git a/src/i18next.js b/src/i18next.js
index 323e6b0fe..f8cb935a7 100644
--- a/src/i18next.js
+++ b/src/i18next.js
@@ -1,5 +1,6 @@
import i18next from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
+import _isString from 'lodash/isString'
import { whitelist, defaultLanguage } from 'redux/constants'
import { setItem } from 'utils/localstorage'
import en from './i18n/en.json'
@@ -13,6 +14,12 @@ const lngDetector = new LanguageDetector()
lngDetector.addDetector({
name: 'customDetector',
lookup() {
+ const language = navigator.language || navigator.userLanguage
+
+ if (_isString(language)) {
+ return language.substring(0, 2)
+ }
+
return defaultLanguage
},
cacheUserLanguage(lng) {
@@ -24,7 +31,7 @@ i18next
.use(lngDetector)
.init({
detection: {
- order: ['localStorage', 'navigator', 'customDetector'],
+ order: ['localStorage', 'customDetector'],
lookupLocalStorage: 'language',
},
interpolation: {