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

59
i18n/en.toml Normal file
View File

@ -0,0 +1,59 @@
[404message]
other = "This is not the page you were looking for"
[searchbarTxt]
other = "Search"
[tags]
other = "Tags"
[date]
other = "Date"
[continueReading]
other = "Continue reading"
[previousPage]
other = "Previous page"
[nextPage]
other = "Next page"
[shareOnTheFediverse]
other = "Share on the Fediverse"
[enterFediverseInstanceAddress]
other = "Enter your instance's address"
[fediverseInstanceExample]
other = "Eg. mastodon.social"
[cancel]
other = "Cancel"
[share]
other = "Share"
[themeCopyrightNotice]
other = "<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>."
[home]
other = "Home"
[posts]
other = "Posts"
[search]
other = "Search"
[tagsColumn]
other = "Tags:"
[tagColumn]
other = "Tag:"
[morePostsLikeThis]
other = "More posts like this"
[noResultsFound]
other = "No results found"

59
i18n/it.toml Normal file
View File

@ -0,0 +1,59 @@
[404message]
other = "Questa non è la pagina che stavi cercando"
[searchbarTxt]
other = "Cerca"
[tags]
other = "Tag"
[date]
other = "Data"
[continueReading]
other = "Continua a leggere"
[previousPage]
other = "Pagina precedente"
[nextPage]
other = "Pagina successiva"
[shareOnTheFediverse]
other = "Condividi sul Fediverse"
[enterFediverseInstanceAddress]
other = "Inserisci l'indirizzo della tua istanza"
[fediverseInstanceExample]
other = "Es. mastodon.social"
[cancel]
other = "Annulla"
[share]
other = "Condividi"
[themeCopyrightNotice]
other = "<a href='https://gitlab.com/gabmus/hugo-ficurinia'>Tema Ficurinia</a> per <a href='https://gohugo.io'>Hugo</a> creato da <a href='https://gabmus.org'>Gabriele Musco</a>. Disponibile con licenza <a href='https://www.gnu.org/licenses/agpl-3.0.html'>GNU AGPLv3</a>."
[home]
other = "Home"
[posts]
other = "Post"
[search]
other = "Cerca"
[tagsColumn]
other = "Tag:"
[tagColumn]
other = "Tag:"
[morePostsLikeThis]
other = "Altri post come questo"
[noResultsFound]
other = "Nessun risultato trovato"

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,6 @@
{{ now.Format "2006" }} &copy; {{ .Site.Copyright | markdownify }} {{ now.Format "2006" }} &copy; {{ .Site.Copyright | markdownify }}
</small></p> </small></p>
<p><small> <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>. {{ i18n "themeCopyrightNotice" | safeHTML }}
Licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3</a>.
</small></p> </small></p>
</footer> </footer>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<div class="search"> <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> <a class="nerdlink" onclick="newSearch();">&#xf002;</a>
</div> </div>
<script> <script>

View File

@ -1,13 +1,15 @@
{{ if site.Params.enableShareOnFediverse | default false }} {{ 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 id="fediInstanceDialog">
<div class="bg" onclick="closeFediInstanceDialog();"></div> <div class="bg" onclick="closeFediInstanceDialog();"></div>
<div class="dialog"> <div class="dialog">
<h2>Enter your instance's address</h2> <h2>{{ i18n "enterFediverseInstanceAddress" }}</h2>
<input id="fediInstanceInput" placeholder="Eg. mastodon.social" type="text" /> <input id="fediInstanceInput" placeholder='{{ i18n "fediverseInstanceExample" }}' type="text" />
<div class="buttons"> <div class="buttons">
<a class="shareBtn" onclick="closeFediInstanceDialog();">Cancel</a> <a class="shareBtn" onclick="closeFediInstanceDialog();">{{ i18n "cancel" }}</a>
<a class="shareBtn" onclick="shareOnFedi();">Share</a> <a class="shareBtn" onclick="shareOnFedi();">{{ i18n "share" }}</a>
</div> </div>
</div> </div>
</div> </div>

View File

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