Skip to content
Snippets Groups Projects
Commit aa51f7e4 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Merge branch 'dev' into 'prod'

Dev

See merge request spraksamlingane/beta.ordbok.uib.no!130
parents c96d2107 76990928
No related branches found
No related tags found
No related merge requests found
<template>
<v-app id="app">
<div v-if="no_locale">
<v-dialog overlay-opacity="1" overlay-color="tertiary" persistent max-width="600px" v-model="no_locale">
<v-card>
<v-toolbar elevation="0" color="primary" text>
<v-toolbar-title class="language-dialog-title">Ordbøkene</v-toolbar-title></v-toolbar>
<v-card-text class="text--primary">
<v-list three-line>
<v-list-item link v-on:click="choose_locale('nob')">
<v-list-item-content>
<v-list-item-title>Norsk (bokmål)</v-list-item-title>
<v-list-item-subtitle>Vis overskrifter, knapper og menyer på bokmål</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item link v-on:click="choose_locale('nno')">
<v-list-item-content>
<v-list-item-title>Norsk (nynorsk)</v-list-item-title>
<v-list-item-subtitle>Vis overskrifter, knappar og menyar på nynorsk</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item link v-on:click="choose_locale('eng')">
<v-list-item-content>
<v-list-item-title>English</v-list-item-title>
<v-list-item-subtitle>Choose English as display language for headings, buttons and menus</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card-text>
</v-card>
</v-dialog>
</div>
<header>
<TopBar/>
......@@ -63,24 +33,10 @@ import TopBar from './components/TopBar.vue'
export default {
computed: {
no_locale: function() {
return !this.$store.state.currentLocale
},
show_banner_text: function() {
return !this.$route.name || (window.innerHeight > 800 && this.$route.name != 'about' )
}
},
mounted: function(){
if (this.no_locale) {
this._i18n.locale = this.$store.state.locale
}
},
methods: {
choose_locale: function(locale) {
this.$store.commit("setLocale", {value: locale, i18n: this._i18n})
}
},
components: {
TopBar
}
......
......@@ -57,6 +57,7 @@
<span class="subheader">
<span class="header_group_list"
v-if="lemma_group.description">{{lemma_group.description}}</span>
{{lemma_group.genus}}
<span v-if="$store.state.showInflectionNo" class="inflection_classes">{{lemma_group.inflection_classes}}</span>
</span>
......
......@@ -8,7 +8,7 @@
v-model="$parent.pos_selected"
hide-details
:menu-props="{ offsetY: true }"
:placeholder="$t('options.pos')"
:aria-label="$t('options.pos')"
:items="pos_items"
append-icon="expand_more"
@input="updatePos">
......@@ -59,7 +59,7 @@
hide-details
:menu-props="{ offsetY: true }"
dense
:placeholder="$t('options.pos')"
:aria-label="$t('options.pos')"
:items="pos_items"
append-icon="expand_more"
@input="updatePos">
......
......@@ -5,10 +5,16 @@
<v-spacer/>
<v-divider vertical/>
<v-toolbar-items v-if="$route.name == 'about'">
<v-btn text @click.native="back">{{$t('close')}}<v-icon right>close</v-icon></v-btn>
</v-toolbar-items>
<v-toolbar-items>
<v-btn v-if="!$store.state.localeChosen" id="locale_button"
aria-haspopup="dialog"
aria-label="Locale | Visningsspråk"
icon @click.native="chooseLocale = !chooseLocale">
<v-icon>language</v-icon></v-btn>
<v-divider v-if="!$store.state.localeChosen" vertical />
<v-btn id="top_menu"
v-if="$route.name != 'about'"
......@@ -18,6 +24,8 @@
aria-labelledby="menu_label"
text @click.native="menuOpen = !menuOpen">
<span id="menu_label">{{$t('menu.title')}}</span><v-icon right>{{menuOpen? 'close' : 'menu'}}</v-icon></v-btn>
<v-btn v-if="$route.name == 'about'" text @click.native="back">{{$t('close')}}<v-icon right>close</v-icon></v-btn>
</v-toolbar-items>
<v-divider vertical/>
</v-app-bar>
......@@ -25,6 +33,35 @@
:close-on-content-click="false" transition="dialog-top-transition">
<Menu @close="menuOpen=false"/>
</v-dialog>
<v-dialog max-width="600px" v-model="chooseLocale">
<v-card>
<v-toolbar elevation="0" color="primary" text>
<v-toolbar-title class="language-dialog-title">Locale | Visningsspråk</v-toolbar-title></v-toolbar>
<v-card-text class="text--primary">
<v-list three-line>
<v-list-item link v-on:click="choose_locale('nob')">
<v-list-item-content>
<v-list-item-title>Norsk (bokmål)</v-list-item-title>
<v-list-item-subtitle>Vis overskrifter, knapper og menyer på bokmål</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item link v-on:click="choose_locale('nno')">
<v-list-item-content>
<v-list-item-title>Norsk (nynorsk)</v-list-item-title>
<v-list-item-subtitle>Vis overskrifter, knappar og menyar på nynorsk</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item link v-on:click="choose_locale('eng')">
<v-list-item-content>
<v-list-item-title>English</v-list-item-title>
<v-list-item-subtitle>Choose English as display language for headings, buttons and menus</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card-text>
</v-card>
</v-dialog>
</div>
</template>
......@@ -37,6 +74,7 @@ export default {
return {
version_label: process.env.VUE_APP_VERSION_LABEL,
release: process.env.VUE_APP_RELEASE,
chooseLocale: false
}
},
computed: {
......@@ -55,6 +93,10 @@ export default {
},
back: function() {
this.$router.go(-1)
},
choose_locale: function(locale) {
this.$store.commit("setLocale", {value: locale, i18n: this._i18n})
this.chooseLocale = false
}
},
......
......@@ -96,7 +96,7 @@ const store = new Vuex.Store({
state: {
showSearchToolbar: null,
showInflectionNo: null,
currentLocale: 'nno',
currentLocale: null,
collapseArticles: 'auto',
defaultDict: null,
perPage: 20,
......@@ -104,7 +104,8 @@ const store = new Vuex.Store({
noMouse: null,
searchRoute: null,
fulltextHighlight: false,
unavailable: null
unavailable: null,
localeChosen: false
},
mutations: {
initStore(state) {
......@@ -115,21 +116,34 @@ const store = new Vuex.Store({
state.defaultDict = localStorage.getItem('defaultDict') || 'bm,nn'
state.perPage = localStorage.getItem('perPage') || 20
state.collapseArticles = localStorage.getItem('collapseArticles') || 'auto'
state.localeChosen = localStorage.getItem('currentLocale') ? true : false
} catch(e) {
console.log("localStorage unavailable")
state.unavailable = true
}
state.noMouse = navigator.userAgentData? navigator.userAgentData.mobile : !window.matchMedia('(pointer: fine)').matches
if (state.currentLocale) {
i18n.locale = state.currentLocale
if (!state.currentLocale) {
let locales = navigator.languages.map(l => l.split("-")[0])
if (locales.includes("nn")) state.currentLocale = "nno"
else if (locales.includes("nb")) state.currentLocale = "nob"
else {
state.currentLocale = Math.random() < 0.5 ? "nob" : "nno";
if (!state.unavailable) {
localStorage.setItem('currentLocale', state.currentLocale)
}
}
}
i18n.locale = state.currentLocale
state.noMouse = navigator.userAgentData? navigator.userAgentData.mobile : !window.matchMedia('(pointer: fine)').matches
},
setLocale(state, payload) {
Vue.$plausible.trackEvent("set locale", {props: {from: state.currentLocale, to: payload.locale}})
state.currentLocale = payload.value
i18n.locale = payload.value
state.localeChosen = true
if (!state.unavailable) localStorage.setItem("currentLocale", payload.value);
},
setCollapse(state, value) {
Vue.$plausible.trackEvent("set collapse", {props: {from: state.collapseArticles, to: value}})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment