From f32946409a0cc70e242a1ec6d3c2ce54db2cd453 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Fri, 26 Nov 2021 12:55:18 +0100 Subject: [PATCH] start appplying i18n --- src/App.vue | 4 ++-- src/components/Autocomplete.vue | 6 ++++-- src/components/Menu.vue | 8 ++++---- src/i18n.js | 2 +- src/locales/eng.json | 12 +++++++++++- src/locales/nno.json | 2 +- src/locales/nor.json | 29 +++++++++++++++++++++++++++++ vue.config.js | 2 +- 8 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/locales/nor.json diff --git a/src/App.vue b/src/App.vue index 8254f431..8a4e3863 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,14 +15,14 @@ </v-toolbar-items> <v-toolbar-items class="hidden-md-and-up"> <v-divider vertical/> - <v-btn text><span>Meny</span><v-icon right>menu</v-icon></v-btn> + <v-btn text><span>{{$t("menu.title")}}</span><v-icon right>menu</v-icon></v-btn> </v-toolbar-items> </v-toolbar> </header> <div class = "banner"> <h1><a aria-label="Ordbøkene bokmålsordboka og nynorskordboka sitt nettsted" :class="$vuetify.breakpoint.name" href="/" tabindex="1">Ordbøkene</a></h1> - <p class="sub-title"><router-link aria-label="Ordbøkene bokmålsordboka og nynorskordboka sitt nettsted" to="/" tabindex="3">Bokmålsordboka og Nynorskordboka</router-link></p> + <p class="sub-title"><router-link aria-label="Ordbøkene bokmålsordboka og nynorskordboka sitt nettsted" to="/" tabindex="3">{{$t("sub-title")}}</router-link></p> </div> <router-view></router-view> <footer> diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index 46684378..72b52c27 100644 --- a/src/components/Autocomplete.vue +++ b/src/components/Autocomplete.vue @@ -30,10 +30,12 @@ <v-divider vertical/> <v-menu allowOverflow: true> <template v-slot:activator="{ on, attrs }"> - <v-btn min-width="0px" v-bind="attrs" v-on="on" plain depressed color = "primary" text><span v-if="$vuetify.breakpoint.mdAndUp">{{{"bm,nn":"begge ordbøkene", "bm": "bokmålsordboka (bm)", "nn":"nynorskordboka (nn)"}[$parent.lang]}}</span><v-icon>expand_more</v-icon></v-btn> + <v-btn min-width="0px" v-bind="attrs" v-on="on" plain depressed color = "primary" text><span v-if="$vuetify.breakpoint.mdAndUp"> + {{$t(`dicts.${$parent.lang}`)}} + </span><v-icon>expand_more</v-icon></v-btn> </template> <v-list> - <v-list-item v-for="item in [{label:'begge ordbøkene', tag:'bm,nn'},{label:'bokmålsordboka (bm)', tag:'bm'},{label:'nynorskordboka (nn)', tag:'nn'}]" :key="item.tag" + <v-list-item v-for="item in ['bm,nn','bm','nn'].map(l => {return {label: $t(`dicts.${l}`), tag: l}})" :key="item.tag" active-class="v-list-item--active" :class="$parent.lang == item.tag ? 'v-list-item--active' : ''" @click="$parent.update_lang_form(item.tag)"> <v-list-item-title >{{ item.label }}</v-list-item-title> </v-list-item> diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 2c1d33d7..2d231d71 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -8,7 +8,7 @@ @click="$emit('close')" dark text - >Lukk + >{{$t("close")}} <v-icon>close</v-icon> </v-btn> </v-toolbar-items> @@ -20,7 +20,7 @@ </v-list> <v-list subheader max-width="250"> - <v-subheader>Visningsspråk</v-subheader> + <v-subheader>{{$t("settings.locale")}}</v-subheader> <v-select rounded v-model="updateLocale" prepend-inner-icon="language" @@ -31,7 +31,7 @@ </v-list> <v-divider></v-divider> <v-list three-line subheader> - <v-subheader>Instillinger</v-subheader> + <v-subheader>{{$t("settings.title")}}</v-subheader> <v-checkbox v-model="toggleSearchToolbar" label="Vis verktøylinje for søkealternativer" @@ -52,7 +52,7 @@ <v-card-actions><v-spacer/> <v-btn rounded depressed @click='resetStore'>Tilbakestill</v-btn> - <v-btn rounded depressed @click="$emit('close')">Lukk</v-btn> + <v-btn rounded depressed @click="$emit('close')">{{$t("close")}}</v-btn> </v-card-actions> diff --git a/src/i18n.js b/src/i18n.js index a40dc7d5..9fae973e 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -19,6 +19,6 @@ function loadLocaleMessages () { export default new VueI18n({ - fallbackLocale: 'nob', + fallbackLocale: 'nor', messages: loadLocaleMessages() }) diff --git a/src/locales/eng.json b/src/locales/eng.json index b8b2a628..2241996b 100644 --- a/src/locales/eng.json +++ b/src/locales/eng.json @@ -1,3 +1,13 @@ { - "menu": "menu" + "sub-title": "Bokmål and Nynorsk dictionaries", + "dicts": { + "nn": "nynorsk dictionary (nn)", + "bm": "bokmål dictionary (bm)", + "bm,nn": "both dictionaries" +}, + "menu": "menu", + "close": "close", + "settings": { + "title": "Settings" + } } \ No newline at end of file diff --git a/src/locales/nno.json b/src/locales/nno.json index 82e9bdc1..077404aa 100644 --- a/src/locales/nno.json +++ b/src/locales/nno.json @@ -1,3 +1,3 @@ { - "menu": "meny" + } \ No newline at end of file diff --git a/src/locales/nor.json b/src/locales/nor.json new file mode 100644 index 00000000..7f0ce6eb --- /dev/null +++ b/src/locales/nor.json @@ -0,0 +1,29 @@ +{ + "sub-title": "Bokmålsordboka og Nynorskordboka", + "dicts": { + "nn": "nynorskorboka (nn)", + "bm": "bokmålsordboka (bm)", + "bm,nn": "begge ordbøkene" + }, + "menu": { + "title": "Meny", + "help-and-info": "Hjelp og informasjon", + "about": "Om ordbøkene", + "reset": "Tilbakestill" + }, + "settings": { + "title": "Instillinger", + "showSearchToolbar": "Vis verktøylinje for søkealternativer", + "showHGNO": "Vis homografnumre", + "showInflectionNo": "Vis bøyningsnumre", + "locale": "Visningsspråk (påvirker ikke innholdet i artiklene)" + }, + "error": { + "dicts": { + "nn": "Nynorskorboka", + "bm": "Bokmålsordboka", + "bm,nn": "ordbøkene" + } + }, + "close": "Lukk" +} \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index c730a957..5822ce0a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -11,7 +11,7 @@ module.exports = { pluginOptions: { i18n: { - fallbackLocale: 'nob', + fallbackLocale: 'nor', localeDir: 'locales', enableInSFC: true, includeLocales: false, -- GitLab