Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
Språksamlingane
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
No related tags found
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 @@
<v-subheader>
Visningsspråk
</v-subheader>
<v-select
rounded
:value=
"$store.state.currentLocale"
@
input=
"changeLocale"
v-model=
"updateLocale"
prepend-inner-icon=
"language"
outlined
:items=
"locales"
...
...
@@ -66,7 +65,8 @@ export default {
name
:
"
Menu
"
,
data
()
{
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
:
{
...
...
@@ -85,15 +85,17 @@ export default {
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
:
{
changeLocale
:
function
(
event
)
{
console
.
log
(
event
)
},
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, {
Vue
.
$plausible
.
enableAutoPageviews
()
// All interaction with local storage is encapsulated in vuex
const
store
=
new
Vuex
.
Store
({
strict
:
true
,
state
:
{
...
...
@@ -32,28 +33,35 @@ const store = new Vuex.Store({
state
.
showSearchToolbar
=
localStorage
.
getItem
(
'
showSearchToolbar
'
)
||
false
state
.
showHGNO
=
localStorage
.
getItem
(
'
showHGNO
'
)
||
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
)
{
state
.
currentLocale
=
loc
ale
i18n
.
locale
=
loc
ale
localStorage
.
setItem
(
"
currentLocale
"
,
loc
ale
);
set
Locale
(
state
,
payload
)
{
state
.
currentLocale
=
payload
.
v
al
u
e
payload
.
i18n
.
locale
=
payload
.
v
al
u
e
localStorage
.
setItem
(
"
currentLocale
"
,
payload
.
v
al
u
e
);
},
toggle
(
state
,
setting
)
{
let
value
=
!
state
[
setting
]
state
[
setting
]
=
value
localStorage
.
setItem
(
setting
,
value
);
}
},
actions
:
{
resetStore
(
context
)
{
},
resetStore
()
{
localStorage
.
removeItem
(
"
showSearchToolbar
"
)
localStorage
.
removeItem
(
"
showHGNO
"
)
localStorage
.
removeItem
(
"
showInflectionNo
"
)
localStorage
.
removeItem
(
"
currentLocale
"
)
context
.
commit
(
"
initStore
"
)
this
.
commit
(
"
initStore
"
)
},
}
},
})
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