Skip to content

Commit 76e4b71

Browse files
Jan SteinkeBud Parr
authored andcommitted
add i18n translation support (#156)
* add initial translation * readd _copy params to templates
1 parent e418548 commit 76e4b71

5 files changed

Lines changed: 40 additions & 6 deletions

File tree

i18n/de.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[more]
2+
other = "Mehr"
3+
4+
[allTitle]
5+
other = "Alle {{.Title }}"
6+
7+
[recentTitle]
8+
other = "Neuste {{.Title }}"
9+
10+
[readMore]
11+
other = "weiterlesen"
12+
13+
[whatsInThis]
14+
other = "Was ist in dieser {{ .Type }}"
15+
16+
[related]
17+
other = "Ähnliches"

i18n/en.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[more]
2+
other = "More"
3+
4+
[allTitle]
5+
other = "All {{.Title }}"
6+
7+
[recentTitle]
8+
other = "Recent {{.Title }}"
9+
10+
[readMore]
11+
other = "read more"
12+
13+
[whatsInThis]
14+
other = "What's in this {{ .Type }}"
15+
16+
[related]
17+
other = "Related"

layouts/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{{/* Use $section_name to get the section title. Use "with" to only show it if it exists */}}
1717
{{ with .Site.GetPage "section" $section_name }}
1818
<h1 class="flex-none">
19-
{{$.Param "recent_copy" | default "Recent" }} {{ .Title }}
19+
{{ $.Param "recent_copy" | default (i18n "recentTitle" .) }}
2020
</h1>
2121
{{ end }}
2222

@@ -33,7 +33,7 @@ <h1 class="flex-none">
3333

3434
{{ if ge $section_count (add $n_posts 1) }}
3535
<section class="w-100">
36-
<h1 class="f3">More</h1>
36+
<h1 class="f3">{{ i18n "more" }}</h1>
3737
{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}}
3838
{{ range (first 4 (after $n_posts $section)) }}
3939
<h2 class="f5 fw4 mb4 dib mr3">
@@ -45,7 +45,7 @@ <h2 class="f5 fw4 mb4 dib mr3">
4545

4646
{{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}}
4747
{{ with .Site.GetPage "section" $section_name }}
48-
<a href="{{ .URL }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">All {{.Title }}</a>
48+
<a href="{{ .URL }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a>
4949
{{ end }}
5050
</section>
5151
{{ end }}

layouts/partials/menu-contextual.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{{- if .Params.toc -}}
77
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
8-
<p class="f5 b mb3">What's in this {{ humanize .Type }}</p>
8+
<p class="f5 b mb3">{{ i18n "whatsInThis" humanize .Type }}</p>
99
{{ .TableOfContents }}
1010
</div>
1111
{{- end -}}
@@ -19,7 +19,7 @@
1919

2020
{{ with $related }}
2121
<div class="bg-light-gray pa3 nested-list-reset nested-copy-line-height nested-links">
22-
<p class="f5 b mb3">Related</p>
22+
<p class="f5 b mb3">{{ i18n "related" }}</p>
2323
<ul class="pa0 list">
2424
{{ range . }}
2525
<li class="mb2">

layouts/partials/summary-with-image.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1 class="f3 fw1 athelas mt0 lh-title">
2020
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
2121
{{ .Summary }}
2222
</div>
23-
<a href="{{.URL}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{$.Param "read_more_copy" | default "read more" }}</a>
23+
<a href="{{.URL}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
2424
{{/* TODO: add author
2525
<p class="f6 lh-copy mv0">By {{ .Author }}</p> */}}
2626
</div>

0 commit comments

Comments
 (0)