-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Add language switcher #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d370d83
feat: Add language switcher
MoritzWeber0 27f20b6
fix: Stay on same page after switching language
MoritzWeber0 232c574
Merge remote-tracking branch 'origin/main' into feat/language-switcher
MoritzWeber0 ae2d51c
Merge branch 'main' into feat/language-switcher
MoritzWeber0 60e025d
Merge branch 'main' into feat/language-switcher
lenderom 781c009
i18n: Add French translation
MoritzWeber0 80060b2
Merge branch 'main' into feat/language-switcher
MoritzWeber0 a82e4a0
Merge remote-tracking branch 'origin/main' into feat/language-switcher
MoritzWeber0 27b3ba3
fix: Add color to language switcher button
MoritzWeber0 a5cd9d9
fix: Add title attribute to button
MoritzWeber0 cabc04d
Merge remote-tracking branch 'origin/main' into feat/language-switcher
MoritzWeber0 6c09aa0
feat: Improve accessbility for language switcher
MoritzWeber0 8cba99f
Merge branch 'main' into feat/language-switcher
therobrob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| document.addEventListener('DOMContentLoaded', function() { | ||
| const languageSwitcher = document.querySelector('.o-language-switcher'); | ||
|
|
||
| if (!languageSwitcher) return; | ||
|
|
||
| const button = languageSwitcher.querySelector('.o-language-switcher__button'); | ||
| const dropdown = languageSwitcher.querySelector('.o-language-switcher__dropdown'); | ||
|
|
||
| button.addEventListener('click', function() { | ||
| const expanded = button.getAttribute('aria-expanded') === 'true'; | ||
| button.setAttribute('aria-expanded', !expanded); | ||
| dropdown.setAttribute('aria-hidden', expanded); | ||
| }); | ||
|
|
||
| document.addEventListener('click', function(event) { | ||
| if (!languageSwitcher.contains(event.target)) { | ||
| button.setAttribute('aria-expanded', 'false'); | ||
| dropdown.setAttribute('aria-hidden', 'true'); | ||
| } | ||
| }); | ||
|
|
||
| document.addEventListener('keydown', function(event) { | ||
| if (event.key === 'Escape' && button.getAttribute('aria-expanded') === 'true') { | ||
| button.setAttribute('aria-expanded', 'false'); | ||
| dropdown.setAttribute('aria-hidden', 'true'); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
|
|
||
| {{ $logo := resources.Get "images/logo.svg" }} | ||
| <div class="o-container o-header__wrapper"> | ||
| <a id="skip-link" class="o-header__skip-link" href="#content">{{ T "skipToContent" }}</a> | ||
| <a href="{{ .Site.BaseURL | relLangURL }}" aria-label="{{ T "home-page-text" }}" class="o-header__logo"> | ||
| <img aria-hidden="true" src="{{ $logo.RelPermalink }}" alt=""> | ||
| </a> | ||
| <div class="o-header__curtain"></div> | ||
| <div class="o-header__nav o-container"> | ||
| <li class="o-header__item a-theme-toggle--mobile"> | ||
| {{ partial "theme-toggle" }} | ||
| </li> | ||
| <button class="o-nav__menu-button" title="Menü öffnen" aria-expanded="false" aria-haspopup="true"> | ||
| <span>{{ T "menu-open" }}</span> | ||
| {{ partial "icon" "menu" }} | ||
| </button> | ||
| <nav> | ||
| <button class="o-nav__close-button" title="Menü schließen"> | ||
| <span>{{ T "menu-close" }}</span> | ||
| {{ partial "icon" "close" }} | ||
| </button> | ||
| <menu> | ||
| <li class="o-header__item"> | ||
| <button class="o-header__expand-button" aria-haspopup="true" aria-expanded="false"> | ||
| <span>{{ T "countries.selection" }}</span> | ||
| {{ partial "icon" "keyboard_arrow_down" }} | ||
| </button> | ||
| <span id="menu-country-list-title">{{ T "country" }}</span> | ||
| <menu class="o-header__item-countries" aria-describedby="menu-country-list-title"> | ||
| {{ range where site.RegularPages "Section" "country"}} | ||
| <li class="o-header__item"> | ||
| <a href="{{ .Permalink }}">{{ .Title }}</a> | ||
| </li> | ||
| {{ end }} | ||
| </menu> | ||
| </li> | ||
| <li class="o-header__item"> | ||
| <span id="menu-general-list-title">{{ T "general" }}</span> | ||
| <ul aria-describedby="menu-general-list-title"> | ||
| <li class="o-header__item a-theme-toggle--desktop"> | ||
| {{ partial "theme-toggle" }} | ||
| </li> | ||
| {{ $news := site.GetPage "news" }} | ||
| {{ if $news }} | ||
| <li class="o-header__item"> | ||
| <a href="{{ $news.RelPermalink }}">{{ $news.Title }}</a> | ||
| </li> | ||
| {{ end }} | ||
| {{ $informationPage := site.GetPage "generalInformation" }} | ||
| {{ if $informationPage }} | ||
| <li class="o-header__item"> | ||
| <a href="{{ $informationPage.RelPermalink }}">{{ $informationPage.Title }}</a> | ||
| </li> | ||
| {{ end }} | ||
| </ul> | ||
| </li> | ||
| </menu> | ||
| </nav> | ||
| </div> | ||
| </div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.