Implemented i18n support for theme strings like Home and Search.

This commit is contained in:
Fredrik Jonsson 2017-06-19 11:09:12 +02:00
commit cd457d7bcd
7 changed files with 40 additions and 6 deletions

17
i18n/en.toml Normal file
View file

@ -0,0 +1,17 @@
[menu_home]
other = "Home"
[pager_next]
other = "Next"
[pager_prev]
other = "Prev"
[taxo_tags]
other = "Tags"
[search_placeholder]
other = "Search"
[search_title]
other = "Enter the terms you wish to search for."

18
i18n/sv.toml Normal file
View file

@ -0,0 +1,18 @@
[menu_home]
other = "Hem"
[pager_next]
other = "Nästa"
[pager_prev]
other = "Föregående"
[taxo_tags]
other = "Taggar"
[search_placeholder]
other = "Sök"
[search_title]
other = "Ange de villkor du vill söka efter."

View file

@ -4,7 +4,7 @@
<nav class="main-menu" role="navigation">
<h2 class="visually-hidden">Main menu</h2>
<ul class="navbar clearfix">
<li><a class="{{ if .IsHome }}active{{ end }}" href="/">Home</a></li>
<li><a class="{{ if .IsHome }}active{{ end }}" href="/">{{ i18n "menu_home" }}</a></li>
{{ range after 1 (where .Site.Pages "Section" "") -}}
<li><a class="{{ if eq $currentID .UniqueID }}active{{ end }}" href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end -}}

View file

@ -1,11 +1,11 @@
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) -}}
<nav class="pager">
{{ if .Paginator.HasPrev -}}
<a href="{{ .Paginator.Prev.URL }}" rel="prev" class="pager-item pager-prev">Prev</a>
<a href="{{ .Paginator.Prev.URL }}" rel="prev" class="pager-item pager-prev">{{ i18n "pager_prev" }}</a>
{{ end -}}
{{ if .Paginator.HasNext -}}
<a href="{{ .Paginator.Next.URL }}" rel="next" class="pager-item pager-next">Next</a>
<a href="{{ .Paginator.Next.URL }}" rel="next" class="pager-item pager-next">{{ i18n "pager_next" }}</a>
{{ end -}}
</nav>
{{ end -}}

View file

@ -1,6 +1,6 @@
{{ $domain := .Site.BaseURL | replaceRE "^https?://(www\\.)?([^/]+)/?" "$2" }}
<form class="search-form" method="get" action="https://duckduckgo.com/">
<input type="search" name="q" class="search-text" placeholder="Search" title="Enter the terms you wish to search for." size="{{ $.Param "searchSize" | default "20" }}" maxlength="128">
<input type="search" name="q" class="search-text" placeholder="{{ i18n "search_placeholder" }}" title="{{ i18n "search_title" }}" size="{{ $.Param "searchSize" | default "20" }}" maxlength="128">
<input type="hidden" name="sites" value="{{ $domain }}">
<input type="submit" value="DuckDuckGo Search" class="hidden">
</form>

View file

@ -1,5 +1,5 @@
<div class="tags">
Tags:
{{ i18n "taxo_tags" }}:
<ul>
{{ range .Params.tags -}}
<li><a href="{{ "/tags/" | relURL }}{{ . | urlize }}">{{ . }}</a></li>

View file

@ -15,4 +15,3 @@ min_version = 0.23
name = "Drupal zen base theme"
homepage = "https://www.drupal.org/project/zen"
repo = "http://drupalcode.org/zen"