From 4464e3c90bb96e1ce26790dcaa51e0553b5fcdb3 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Thu, 6 Jan 2022 16:13:01 +0100 Subject: [PATCH] Show dialog if locale not detected --- src/App.vue | 56 ++++++++++++++++++++++++++++++++++++++++++++++------- src/main.js | 9 ++++----- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/App.vue b/src/App.vue index 80a344e8..07f51792 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,35 @@ <template> <v-app id="app"> + <div v-if="no_locale"> + <v-dialog overlay-opacity="1" overlay-color="tertiary" persistent max-width="600px" v-if="!this.$store.state.currentLocale" 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('eng')"> + <v-list-item-content> + <v-list-item-title>English</v-list-item-title> + <v-list-item-subtitle>Choose english as display language for buttons and menus</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 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('nob')"> + <v-list-item-content> + <v-list-item-title>Norsk (bokmål)</v-list-item-title> + <v-list-item-subtitle>Vis knapper og menyer på bokmål</v-list-item-subtitle> + </v-list-item-content> + </v-list-item> + </v-list> + </v-card-text> + </v-card> + </v-dialog> + </div> <header> <TopBar/> </header> @@ -24,17 +54,30 @@ </div> <div>Bokmålsordboka og Nynorskordboka viser skrivemåte og bøying i tråd med norsk rettskriving. Språkrådet og Universitetet i Bergen står bak ordbøkene. Gi oss gjerne tilbakemelding på <a href="mailto:ordbok-beta@uib.no">ordbok-beta@uib.no</a>.</div> </footer> - </v-app> </template> <script> import TopBar from './components/TopBar.vue' export default { + computed: { + no_locale: function() { + return !this.$store.state.locale + } + }, mounted: function(){ - this._i18n.locale = this.$store.state.currentLocale + if (!this.no_locale) { + this._i18n.locale = this.$store.state.locale + } document.title = 'Ordbøkene - ' + process.env.VUE_APP_VERSION_LABEL }, + methods: { + choose_locale: function(locale) { + this.locale_chosen = true + this.$store.commit("setLocale", {value: locale, i18n: this._i18n}) + } + + }, components: { TopBar } @@ -62,6 +105,7 @@ import TopBar from './components/TopBar.vue' display: flex; flex-direction: column; height: 100%; + background-color: var(--v-tertiary-base) } html, body { @@ -115,14 +159,12 @@ h1 > a.xs, h1 > a.sm { margin-left: 10px; } -.about-link > a{ - border-bottom: solid var(--v-primary-base) 2px; - font-size: 12px; - color: var(--v-primary-base) !important; +.language-dialog-title { + font-family: Inria Serif; + color: white; } - footer { position: relative; padding-left: calc((100vw - 1200px) / 2); diff --git a/src/main.js b/src/main.js index 18efd065..7ba7a3c5 100644 --- a/src/main.js +++ b/src/main.js @@ -108,12 +108,11 @@ const store = new Vuex.Store({ state.collapseArticles = localStorage.getItem('collapseArticles') || window.innerWidth < 700 state.noMouse = window.matchMedia('(hover: none)').matches - let locales = navigator.languages.map(l => l.split("-")[0]) + if (!state.currentLocale) { - if (locales.includes("nn")) state.currentLocale = "nno" - else if (locales.includes("nb")) state.currentLocale = "nob" - else if (locales.includes("no")) state.currentLocale = "nob" - else state.currentLocale = "eng" + let locale = navigator.language.split("-")[0] + if (locale == "nn") state.currentLocale = "nno" + else if (locale == "nb") state.currentLocale = "nob" } }, -- GitLab