✨ Use country code for national party in results
This commit is contained in:
parent
3112a09985
commit
6dcec82e05
|
@ -83,7 +83,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getCurrentLocale, getTranslatedUrl } from '@/i18n/helper'
|
||||
import { getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
|
||||
import {
|
||||
MAX_POINTS,
|
||||
BASE_POINTS,
|
||||
|
@ -236,7 +236,7 @@
|
|||
score: this.scores
|
||||
.map(t => t.scores.find(s => s.party === party.id).score)
|
||||
.reduce(addUp, 0),
|
||||
nationalParty: party['national_parties'][getCurrentLocale()]
|
||||
nationalParty: party['national_parties'][getUserLanguage().country]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,8 @@
|
|||
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@/config'
|
||||
import i18n from './index'
|
||||
|
||||
console.log('i18n', i18n)
|
||||
|
||||
export const isLangSupported = lang =>
|
||||
SUPPORTED_LOCALES.some(([locale]) => locale === lang)
|
||||
|
||||
|
@ -18,11 +20,14 @@ export function getUserLanguage () {
|
|||
window.navigator.userLanguage ||
|
||||
DEFAULT_LOCALE
|
||||
)
|
||||
return lang.split('-')[0]
|
||||
return {
|
||||
language: lang.split('-')[0],
|
||||
country: lang.split('-')[1].toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserSupportedLanguage () {
|
||||
const language = getUserLanguage()
|
||||
const { language } = getUserLanguage()
|
||||
return isLangSupported(language)
|
||||
? language
|
||||
: DEFAULT_LOCALE
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue