Skip to content

Commit

Permalink
Added a language selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Mar 8, 2018
1 parent 9f8c7cb commit e56f50a
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 10 deletions.
42 changes: 42 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,45 @@ other = "on"

[string_recent_content]
other = "Recent content"

[contact_js]
other = "You must have Javascript enabled to use this contact form."

[contact_submitted]
other = "Your message was sent."

[contact_error]
other = "There was an error sending the message."

[contact_name]
other = "Name"

[contact_name_placeholder]
other = "Your name"

[contact_mail]
other = "E-mail address"

[contact_mail_placeholder]
other = "Your e-mail address"

[contact_subject]
other = "Subject"

[contact_subject_placeholder]
other = "A short subject"

[contact_message]
other = "Message"

[contact_message_placeholder]
other = "The messages goes here…"

[contact_submit]
other = "Send message"

[contact_honypot]
other = "Skip if you are a human"

[lang_select_title]
other = "Language selector"
42 changes: 42 additions & 0 deletions i18n/sv.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,45 @@ other = "på"

[string_recent_content]
other = "Senaste innehåll"

[contact_js]
other = "Du behöver ha Javascript aktiverat för att använda detta kontaktformulär."

[contact_submitted]
other = "Ditt meddelande har skickats."

[contact_error]
other = "Det blev ett fel när meddelandet skickades."

[contact_name]
other = "Namn"

[contact_name_placeholder]
other = "Ditt namn"

[contact_mail]
other = "E-postadress"

[contact_mail_placeholder]
other = "Din e-postadress"

[contact_subject]
other = "Rubrik"

[contact_subject_placeholder]
other = "En kort rubrik"

[contact_message]
other = "Meddelande"

[contact_message_placeholder]
other = "Meddelandet skrivs här…"

[contact_submit]
other = "Skicka meddelande"

[contact_honypot]
other = "Hoppa över ifall du är människa."

[lang_select_title]
other = "Språkväljare"
9 changes: 6 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
<body>
<div class="page layout__page{{ if $.Param "sidebar" | default true }} layout__sidebar-second{{ end }}">
<header class="header layout__header" role="banner">
{{ if $.Param "logo" | default true }}<a href="{{ "/" | relURL }}" title="Home" rel="home" class="header__logo"><img src="{{ "/images/logo.png" | relURL }}" alt="Home" class="header__logo-image"></a>{{ end }}
{{ if $.Param "logo" | default true }}<a href="{{ "/" | relLangURL }}" title="Home" rel="home" class="header__logo"><img src="{{ "/images/logo.png" | relURL }}" alt="Home" class="header__logo-image"></a>{{ end }}
<h1 class="header__site-name">
<a href="{{ "/" | relURL }}" title="Home" class="header__site-link" rel="home"><span>{{ .Site.Title }}</span></a>
<a href="{{ "/" | relLangURL }}" title="Home" class="header__site-link" rel="home"><span>{{ .Site.Title }}</span></a>
</h1>
<div class="region header__region">{{ if $.Param "search" }}{{ partialCached "search.html" . }}{{ end }}</div>
<div class="region header__region">
{{ if .Site.IsMultiLingual }}{{ partial "language-selector.html" . }}{{ end }}
{{ if $.Param "search" }}{{ partialCached "search.html" . }}{{ end }}
</div>
</header>

{{ partial "menu.html" . }}
Expand Down
21 changes: 21 additions & 0 deletions layouts/partials/language-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h2 class="visually-hidden">{{ i18n "lang_select_title" }}</h2>
<nav class="language-selector layout__language-selector" role="navigation">
<ul class="navbar">

{{ if .IsTranslated -}}
{{ range .Translations }}
<li><a rel="alternate" href="{{ .RelPermalink }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Site.Language.Params.LanguageName }}</a></li>
{{ end -}}

{{ else -}}

{{ range .Site.Languages -}}
{{ if ne $.Site.Language.Lang .Lang }}
<li><a rel="alternate" href="/{{ .Lang }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Params.LanguageName }}</a></li>
{{ end -}}
{{ end -}}


{{ end -}}
</ul>
</nav>
2 changes: 1 addition & 1 deletion layouts/partials/menu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ $home := relURL "/" }}
{{ $home := relLangURL "/" }}
{{ $currentSection := .Section }}
{{ $currentID := .UniqueID }}
<nav class="main-menu layout__navigation" role="navigation">
Expand Down
20 changes: 20 additions & 0 deletions sass/_zen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ figcaption {
}
}

.language-selector,
article > header,
.content-dates,
.footer {
Expand Down Expand Up @@ -282,6 +283,25 @@ figcaption {
@include type-layout(l, 1);
}

// Language selector

.language-selector {
position: relative;
padding-left: 32px;

&::before {
content: '';
position: absolute;
top: 0;
left: 0;
background-image: url('../images/language-icon.png');
background-size: 24px;
background-repeat: no-repeat;
height: 24px;
width: 24px;
}
}

// Form

.content {
Expand Down
10 changes: 5 additions & 5 deletions sass/navigation/mobile/_mobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
transform: translateX(100vw);
z-index: 21;

a {
color: color(text-bg);
text-decoration: none;
}

.js-nav-open & {
pointer-events: auto;
box-shadow: -10px 0 10px -10px color(nearblack);
Expand All @@ -84,11 +89,6 @@
li {
list-style-type: none;
margin: .4rem 0;

a {
color: color('white');
text-decoration: none;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/css/styles.css

Large diffs are not rendered by default.

Binary file added static/images/language-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e56f50a

Please sign in to comment.