🐛 Use default user country

This commit is contained in:
Moritz Kröger 2019-05-09 15:05:42 +01:00
parent 51e465ce43
commit 50c4f93a2c
3 changed files with 8 additions and 5 deletions

View file

@ -33,14 +33,14 @@
import { GA_COOKIE_NAME } from '@/config/analytics'
import { SUPPORTED_LOCALES } from '@/config'
import { setCookie, getCookie } from '@/helper/cookies'
import { getCountryByIP, getTranslatedUrl } from '@/i18n/helper'
import { getCountryByIP, getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
export default {
name: 'App',
data () {
return {
userCountry: null,
userCountry: getUserLanguage().country,
showConsentLayer: getCookie(GA_COOKIE_NAME) === null,
euromatLogo: require('@/assets/svg/euromat-logo.svg'),
logoSize: 220,

View file

@ -24,11 +24,14 @@ export function getUserLanguage () {
window.navigator.userLanguage ||
DEFAULT_LOCALE
)
return lang.split('-')[0]
return {
language: lang.split('-')[0],
country: lang.split('-')[1]
}
}
export function getUserSupportedLanguage () {
const language = getUserLanguage()
const { language } = getUserLanguage()
return isLangSupported(language)
? language
: DEFAULT_LOCALE

View file

@ -11,7 +11,7 @@ export function getPageTitle (data = {}) {
export function beforeEnter (to, from, next) {
const lang = to.params.locale
if (!i18n.isLangSupported(lang)) {
return next(i18n.getUserLanguage())
return next(i18n.getUserLanguage().language)
}
i18n.setCurrentLocale(lang)