added support for translations, added italian translation

This commit is contained in:
Gabriele Musco 2021-07-07 14:33:45 +02:00
parent 6bb8b3952d
commit 9f0fd3337b
No known key found for this signature in database
GPG key ID: 8539FD3454380B83
16 changed files with 162 additions and 33 deletions

View file

@ -1,7 +1,7 @@
{{ define "main" }}
<article>
<h1>
This is not the page you were looking for
{{ i18n "404message" }}
</h1>
</article>
{{ end }}

View file

@ -25,7 +25,7 @@
));
if (articles.length > 0) renderArticles(articles);
else document.getElementById('postlist').innerHTML = `
<h3>No results found</h3>
<h3>{{ i18n "noResultsFound" | safeJS }}</h3>
`;
});
}

View file

@ -4,8 +4,8 @@
<h1>{{ .Title }}</h1>
{{ if (.Params.showDate | default true) }}
<p class="date">
<span title="Date"></span>
{{ .Date.Format "2006-01-02" }}
<span title='{{ i18n "date" }}'></span>
{{- partial "date.html" .Date -}}
</p>
{{ end }}
{{ if .Params.Image }}
@ -17,7 +17,7 @@
{{ if not .Site.Params.discreteCards }}<hr />{{ end }}
<p class="articleTagsContainer">
<span></span>
<strong>Tags:</strong>
<strong>{{ i18n "tagsColumn" }}</strong>
{{ range sort .Params.tags }}
<a
{{ if site.Params.discreteTags | default false }}

View file

@ -4,11 +4,11 @@
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h2>
<p class="date">
<span title="Date"></span>
{{ .Date.Format "2006-01-02" }}
<span title='{{ i18n "date" }}'></span>
{{- partial "date.html" .Date -}}
{{ if and (site.Params.tagsInArticlePreview | default true) .Params.tags }}
| <!-- Pipe character as visual separator between date and tags-->
<span title="Tags"></span>
<span title='{{ i18n "tags" }}'></span>
{{ range sort .Params.tags }}
<a href="/tags/{{ . | urlize }}">#{{ . }}</a>
{{ end }}
@ -22,7 +22,7 @@
{{ if (site.Params.articleSummary | default true) }}
<div class="articlePreview">
<p>{{ .Summary }}</p>
<p><a href="{{ .Permalink }}">Continue reading</a></p>
<p><a href="{{ .Permalink }}">{{ i18n "continueReading" }}</a></p>
</div>
{{ end }}
</div>

View file

@ -0,0 +1,5 @@
{{ if eq site.Language.Lang "it" }}
{{ .Format "02-01-2006" }}
{{ else }}
{{ .Format "2006-01-02" }}
{{ end }}

View file

@ -12,11 +12,11 @@
<div class="contentArea">
<h2>{{ .Title }}</h2>
<p class="date">
<span title="Date"></span>
{{ .Date.Format "2006-01-02" }}
<span title='{{ i18n "date" }}'></span>
{{- partial "date.html" .Date -}}
{{ if and (site.Params.tagsInArticlePreview | default true) .Params.tags }}
<br />
<span title="Tags"></span>
<span title='{{ i18n "tags" }}'></span>
{{ range sort .Params.tags }}
#{{ . }}
{{ end }}

View file

@ -6,7 +6,6 @@
{{ now.Format "2006" }} &copy; {{ .Site.Copyright | markdownify }}
</small></p>
<p><small>
<a href="https://gitlab.com/gabmus/hugo-ficurinia">Ficurinia theme</a> for <a href="https://gohugo.io">Hugo</a> by <a href="https://gabmus.org">Gabriele Musco</a>.
Licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3</a>.
{{ i18n "themeCopyrightNotice" | safeHTML }}
</small></p>
</footer>

View file

@ -17,9 +17,9 @@
<input type="checkbox" id="main-nav-toggler" />
{{ end }}
<ul id="main-nav">
<li><a href="/">Home</a></li>
<li><a href="/">{{ i18n "home" }}</a></li>
{{ if (.Site.Params.showPostsLink | default true) }}
<li><a href="/posts">Posts</a></li>
<li><a href="/posts">{{ i18n "posts" }}</a></li>
{{ end }}
{{ range site.Params.extraContentDirs }}
<li><a href="/{{ . }}">{{ . | humanize }}</a></li>
@ -35,10 +35,10 @@
<li><a href="{{ .URL | safeURL }}">{{ .Name }}</a></li>
{{ end }}
{{ if (.Site.Params.showTags | default true) }}
<li><a href="/tags">Tags</a></li>
<li><a href="/tags">{{ i18n "tags" }}</a></li>
{{ end }}
{{ if and (.Site.Params.searchMenuLink | default false) (.Site.Params.enableSearch | default true) }}
<li><a href="/search">Search</a></li>
<li><a href="/search">{{ i18n "search" }}</a></li>
{{ end }}
</ul>
</nav>

View file

@ -1,9 +1,10 @@
<script>
function renderTags(tags) {
if (tags.length <= 0) return '';
let res = '| <span title="tags"></span>';
let res = `| <span title='{{ i18n "tags" | safeJS }}'></span>`;
for (let tag of tags) {
res += `<a href="/tags/${tag}">#${tag}</a>`;
// regular space
res += `<a href="/tags/${tag}">#${tag}</a>&#32;`;
}
return res;
}
@ -19,7 +20,7 @@
<a href="${article.link}">${article.title}</a>
</h2>
<p class="date">
<span title="Date"></span>
<span title='{{ i18n "date" | safeJS }}'></span>
${article.date}
{{ if (.Site.Params.tagsInArticlePreview | default true) }}
${renderTags(article.tags)}
@ -31,7 +32,7 @@
{{ if (site.Params.articleSummary | default true) }}
<div class="articlePreview">
<p>${article.summary}</p>
<p><a href="${article.link}">Continue reading</a></p>
<p><a href="${article.link}">{{ i18n "continueReading" | safeJS }}</a></p>
</div>
{{ end }}
</div>

View file

@ -33,7 +33,7 @@
{{ end }}
'>
{{ if .Paginator.HasPrev }}
<a href="{{ .Paginator.Prev.URL }}" title="Previous page">
<a href="{{ .Paginator.Prev.URL }}" title='{{ i18n "previousPage" }}'>
{{ if eq $navtype "circles" }}
{{ else }}
@ -53,7 +53,7 @@
{{ end }}
{{ end }}
{{ if .Paginator.HasNext }}
<a href="{{ .Paginator.Next.URL }}" title="Next page">
<a href="{{ .Paginator.Next.URL }}" title='{{ i18n "nextPage" }}'>
{{ if eq $navtype "circles" }}
{{ else }}

View file

@ -12,7 +12,7 @@
{{ end }}
<div class="relatedArticlesContainer">
<hr />
<h2>More posts like this</h2>
<h2>{{ i18n "morePostsLikeThis" }}</h2>
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}">
{{ range first (.Site.Params.relatedArticlesNum | default 2) $postsList }}
{{- partial "article_card.html" . -}}

View file

@ -1,5 +1,5 @@
<div class="search">
<input id="searchbar" type="text" placeholder="Search" />
<input id="searchbar" type="text" placeholder='{{ i18n "searchbarTxt" }}' />
<a class="nerdlink" onclick="newSearch();">&#xf002;</a>
</div>
<script>

View file

@ -1,13 +1,15 @@
{{ if site.Params.enableShareOnFediverse | default false }}
<a style="margin-bottom: 24px; display: inline-block;" class="shareBtn" onclick="openFediInstanceDialog();">Share on the Fediverse</a>
<a style="margin-bottom: 24px; display: inline-block;" class="shareBtn" onclick="openFediInstanceDialog();">
{{ i18n "shareOnTheFediverse" }}
</a>
<div id="fediInstanceDialog">
<div class="bg" onclick="closeFediInstanceDialog();"></div>
<div class="dialog">
<h2>Enter your instance's address</h2>
<input id="fediInstanceInput" placeholder="Eg. mastodon.social" type="text" />
<h2>{{ i18n "enterFediverseInstanceAddress" }}</h2>
<input id="fediInstanceInput" placeholder='{{ i18n "fediverseInstanceExample" }}' type="text" />
<div class="buttons">
<a class="shareBtn" onclick="closeFediInstanceDialog();">Cancel</a>
<a class="shareBtn" onclick="shareOnFedi();">Share</a>
<a class="shareBtn" onclick="closeFediInstanceDialog();">{{ i18n "cancel" }}</a>
<a class="shareBtn" onclick="shareOnFedi();">{{ i18n "share" }}</a>
</div>
</div>
</div>

View file

@ -4,7 +4,11 @@
{{ if and (ne $section $title) (ne $section "Tags") (ne $title (printf "%ss" $section)) }}
{{ $section }}:
{{ end }}
{{ if and (eq $section "Tags") (ne $section $title) }}Tag: #{{ end }}{{ $title }}
{{ if and (eq $section "Tags") (eq $section $title) }}
{{ i18n "tagsColumn" }}
{{ else }}
{{ if and (eq $section "Tags") (ne $section $title) }}{{ i18n "tagColumn" }} #{{ end }}{{ $title }}
{{ end }}
</h2>
<ul class="list">
{{ if and (eq $section "Tags") (eq $section $title) }}
@ -19,7 +23,7 @@
<li>
<div>
<span class="date">
{{ .Date.Format "2006-01-02" }}
{{- partial "date.html" .Date -}}
</span>
<span>
<a href="{{ .Permalink }}">{{ .Title }}</a>