🐛 Fixes import issue with async methods
This commit is contained in:
parent
50c4f93a2c
commit
cf2bddf130
|
@ -30,10 +30,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import '@/assets/icons/european-stars'
|
import '@/assets/icons/european-stars'
|
||||||
|
import { IPDATA_URL } from '@/config/api'
|
||||||
import { GA_COOKIE_NAME } from '@/config/analytics'
|
import { GA_COOKIE_NAME } from '@/config/analytics'
|
||||||
import { SUPPORTED_LOCALES } from '@/config'
|
import { SUPPORTED_LOCALES } from '@/config'
|
||||||
import { setCookie, getCookie } from '@/helper/cookies'
|
import { setCookie, getCookie } from '@/helper/cookies'
|
||||||
import { getCountryByIP, getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
|
import { getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
|
@ -120,7 +121,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async created () {
|
async created () {
|
||||||
const ipData = await getCountryByIP()
|
const ipResponse = await fetch(IPDATA_URL)
|
||||||
|
const ipData = ipResponse.json()
|
||||||
this.userCountry = ipData.country_code
|
this.userCountry = ipData.country_code
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { DEFAULT_LOCALE } from '@/config'
|
||||||
import i18n from '@/i18n'
|
import i18n from '@/i18n'
|
||||||
import localI18n from './i18n'
|
import localI18n from './i18n'
|
||||||
import { storageAvailable } from '@/helper/storage'
|
import { storageAvailable } from '@/helper/storage'
|
||||||
import { getTranslatedAliases, getTranslatedTitles } from '@/i18n/helper'
|
import { getTranslatedTitles, getTranslatedAliases } from '@/i18n/helper'
|
||||||
|
|
||||||
function hasAnswers (to, from, next) {
|
function hasAnswers (to, from, next) {
|
||||||
if (storageAvailable('sessionStorage') && !sessionStorage.getItem('euromat-answers')) {
|
if (storageAvailable('sessionStorage') && !sessionStorage.getItem('euromat-answers')) {
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@/config'
|
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@/config'
|
||||||
import { IPDATA_URL } from '@/config/api'
|
|
||||||
import i18n from './index'
|
import i18n from './index'
|
||||||
|
|
||||||
export const getCountryByIP = async () => {
|
|
||||||
const response = await fetch(IPDATA_URL)
|
|
||||||
return response.json()
|
|
||||||
}
|
|
||||||
|
|
||||||
export const isLangSupported = lang =>
|
export const isLangSupported = lang =>
|
||||||
SUPPORTED_LOCALES.some(([locale]) => locale === lang)
|
SUPPORTED_LOCALES.some(([locale]) => locale === lang)
|
||||||
|
|
||||||
|
@ -61,6 +55,8 @@ export function getTranslatedAliases (data, section) {
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('getTranslatedAliases inside', getTranslatedAliases)
|
||||||
|
|
||||||
export function getTranslatedUrl (section, prefixUrl, omitLocale = false) {
|
export function getTranslatedUrl (section, prefixUrl, omitLocale = false) {
|
||||||
const messages = i18n.messages[getCurrentLocale()][section]
|
const messages = i18n.messages[getCurrentLocale()][section]
|
||||||
const url = messages.url
|
const url = messages.url
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
|
|
||||||
import * as i18n from '@/i18n/helper'
|
import { getUserSupportedLanguage } from '@/i18n/helper'
|
||||||
import BaseLocaleRouter from '@/components/base-locale-router'
|
import BaseLocaleRouter from '@/components/base-locale-router'
|
||||||
import { getPageTitle, beforeEnter } from '@/router/helper'
|
import { getPageTitle, beforeEnter } from '@/router/helper'
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ const router = new Router({
|
||||||
{
|
{
|
||||||
path: '*',
|
path: '*',
|
||||||
redirect (to) {
|
redirect (to) {
|
||||||
return i18n.getUserSupportedLanguage()
|
return getUserSupportedLanguage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue