Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arsnova-lite
Manage
Activity
Members
Labels
Plan
Issues
24
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
arsnova-lite
Commits
3e3bd63e
Commit
3e3bd63e
authored
6 years ago
by
Lukas Mauß
Browse files
Options
Downloads
Patches
Plain Diff
Remember language in localStorage
parent
99bbd44b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!119
Fix default content group
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/shared/header/header.component.ts
+9
-5
9 additions, 5 deletions
src/app/components/shared/header/header.component.ts
with
9 additions
and
5 deletions
src/app/components/shared/header/header.component.ts
+
9
−
5
View file @
3e3bd63e
import
{
Component
,
EventEmitter
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
AuthenticationService
}
from
'
../../../services/http/authentication.service
'
;
import
{
NotificationService
}
from
'
../../../services/util/notification.service
'
;
import
{
Router
}
from
'
@angular/router
'
;
...
...
@@ -22,13 +22,17 @@ export class HeaderComponent implements OnInit {
public
router
:
Router
,
private
translationService
:
TranslateService
,
private
langService
:
LanguageService
)
{
translationService
.
setDefaultLang
(
this
.
translationService
.
getBrowserLang
());
sessionStorage
.
setItem
(
'
currentLang
'
,
this
.
translationService
.
getBrowserLang
());
}
ngOnInit
()
{
// Subscribe to user data (update component's user when user data changes: e.g. login, logout)
if
(
!
localStorage
.
getItem
(
'
currentLang
'
))
{
const
lang
=
this
.
translationService
.
getBrowserLang
();
this
.
translationService
.
setDefaultLang
(
lang
);
localStorage
.
setItem
(
'
currentLang
'
,
lang
);
}
else
{
this
.
translationService
.
setDefaultLang
(
localStorage
.
getItem
(
'
currentLang
'
));
}
this
.
authenticationService
.
watchUser
.
subscribe
(
newUser
=>
this
.
user
=
newUser
);
}
...
...
@@ -63,7 +67,7 @@ export class HeaderComponent implements OnInit {
useLanguage
(
language
:
string
)
{
this
.
translationService
.
use
(
language
);
session
Storage
.
setItem
(
'
currentLang
'
,
this
.
translationService
.
currentLang
);
local
Storage
.
setItem
(
'
currentLang
'
,
language
);
this
.
langService
.
langEmitter
.
emit
(
language
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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