Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Margunn.Rauset
beta.ordbok.uib.no
Commits
a8f0d221
Commit
a8f0d221
authored
3 years ago
by
Henrik Askjer
Browse files
Options
Downloads
Patches
Plain Diff
detect locale
parent
8be68fa9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Menu.vue
+10
-8
10 additions, 8 deletions
src/components/Menu.vue
src/main.js
+19
-11
19 additions, 11 deletions
src/main.js
with
29 additions
and
19 deletions
src/components/Menu.vue
+
10
−
8
View file @
a8f0d221
...
@@ -22,8 +22,7 @@
...
@@ -22,8 +22,7 @@
<v-subheader>
Visningsspråk
</v-subheader>
<v-subheader>
Visningsspråk
</v-subheader>
<v-select
rounded
<v-select
rounded
:value=
"$store.state.currentLocale"
v-model=
"updateLocale"
@
input=
"changeLocale"
prepend-inner-icon=
"language"
prepend-inner-icon=
"language"
outlined
outlined
:items=
"locales"
:items=
"locales"
...
@@ -66,7 +65,8 @@ export default {
...
@@ -66,7 +65,8 @@ export default {
name
:
"
Menu
"
,
name
:
"
Menu
"
,
data
()
{
data
()
{
return
{
return
{
locales
:
[{
text
:
"
norsk (bokmål)
"
,
value
:
"
nob
"
},
{
text
:
"
norsk (nynorsk)
"
,
value
:
"
nno
"
},
{
text
:
"
english
"
,
value
:
"
eng
"
}]
locales
:
[{
text
:
"
norsk (bokmål)
"
,
value
:
"
nob
"
},
{
text
:
"
norsk (nynorsk)
"
,
value
:
"
nno
"
},
{
text
:
"
english
"
,
value
:
"
eng
"
}],
localesMap
:
{
"
nob
"
:
"
norsk (bokmål)
"
,
"
nno
"
:
"
norsk (nynorsk)
"
,
"
eng
"
:
"
english
"
}
}
}
},
},
computed
:
{
computed
:
{
...
@@ -85,15 +85,17 @@ export default {
...
@@ -85,15 +85,17 @@ export default {
set
()
{
this
.
$store
.
commit
(
"
toggle
"
,
"
showInflectionNo
"
)
set
()
{
this
.
$store
.
commit
(
"
toggle
"
,
"
showInflectionNo
"
)
}
}
},
},
updateLocale
:
{
get
()
{
return
{
text
:
this
.
localesMap
[
this
.
$store
.
state
.
currentLocale
],
value
:
this
.
$store
.
state
.
currentLocale
}},
set
(
value
)
{
this
.
$store
.
commit
(
"
setLocale
"
,
{
value
:
value
,
i18n
:
this
.
_i18n
})
}
}
},
},
methods
:
{
methods
:
{
changeLocale
:
function
(
event
)
{
console
.
log
(
event
)
},
resetStore
:
function
()
{
resetStore
:
function
()
{
this
.
$store
.
dispatch
(
"
resetStore
"
)
this
.
$store
.
commit
(
"
resetStore
"
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.js
+
19
−
11
View file @
a8f0d221
...
@@ -19,6 +19,7 @@ Vue.use(VuePlausible, {
...
@@ -19,6 +19,7 @@ Vue.use(VuePlausible, {
Vue
.
$plausible
.
enableAutoPageviews
()
Vue
.
$plausible
.
enableAutoPageviews
()
// All interaction with local storage is encapsulated in vuex
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
strict
:
true
,
strict
:
true
,
state
:
{
state
:
{
...
@@ -32,28 +33,35 @@ const store = new Vuex.Store({
...
@@ -32,28 +33,35 @@ const store = new Vuex.Store({
state
.
showSearchToolbar
=
localStorage
.
getItem
(
'
showSearchToolbar
'
)
||
false
state
.
showSearchToolbar
=
localStorage
.
getItem
(
'
showSearchToolbar
'
)
||
false
state
.
showHGNO
=
localStorage
.
getItem
(
'
showHGNO
'
)
||
false
state
.
showHGNO
=
localStorage
.
getItem
(
'
showHGNO
'
)
||
false
state
.
showInflectionNo
=
localStorage
.
getItem
(
'
showInflectionNo
'
)
||
false
state
.
showInflectionNo
=
localStorage
.
getItem
(
'
showInflectionNo
'
)
||
false
state
.
currentLocale
=
localStorage
.
getItem
(
'
currentLocale
'
)
||
{
text
:
"
norsk (bokmål)
"
,
value
:
"
nob
"
}
state
.
currentLocale
=
localStorage
.
getItem
(
'
currentLocale
'
)
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
"
}
},
},
change
Locale
(
state
,
locale
,
i18n
)
{
set
Locale
(
state
,
payload
)
{
state
.
currentLocale
=
loc
ale
state
.
currentLocale
=
payload
.
v
al
u
e
i18n
.
locale
=
loc
ale
payload
.
i18n
.
locale
=
payload
.
v
al
u
e
localStorage
.
setItem
(
"
currentLocale
"
,
loc
ale
);
localStorage
.
setItem
(
"
currentLocale
"
,
payload
.
v
al
u
e
);
},
},
toggle
(
state
,
setting
)
{
toggle
(
state
,
setting
)
{
let
value
=
!
state
[
setting
]
let
value
=
!
state
[
setting
]
state
[
setting
]
=
value
state
[
setting
]
=
value
localStorage
.
setItem
(
setting
,
value
);
localStorage
.
setItem
(
setting
,
value
);
}
},
},
resetStore
()
{
actions
:
{
resetStore
(
context
)
{
localStorage
.
removeItem
(
"
showSearchToolbar
"
)
localStorage
.
removeItem
(
"
showSearchToolbar
"
)
localStorage
.
removeItem
(
"
showHGNO
"
)
localStorage
.
removeItem
(
"
showHGNO
"
)
localStorage
.
removeItem
(
"
showInflectionNo
"
)
localStorage
.
removeItem
(
"
showInflectionNo
"
)
localStorage
.
removeItem
(
"
currentLocale
"
)
localStorage
.
removeItem
(
"
currentLocale
"
)
context
.
commit
(
"
initStore
"
)
this
.
commit
(
"
initStore
"
)
},
},
}
},
})
})
const
router
=
new
VueRouter
({
const
router
=
new
VueRouter
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment