WIP: refactor(i18n): translation key renaming

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/63
This commit is contained in:
Jimmy Cai 2020-12-15 13:23:54 +01:00
parent e9c1abac93
commit fba424623f
11 changed files with 57 additions and 56 deletions

View File

@ -1,41 +0,0 @@
[toggleMenu]
other = "Toggle Menu"
[relatedContents]
other = "Related contents"
[lastUpdatedOn]
other ="Last updated on"
[widgetArchivesTitle]
other = "Archives"
[widgetArchivesMore]
other = "More"
[widgetTagCloudTitle]
other = "Tags"
[categoriesTitle]
other = "Categories"
[notFoundTitle]
other = "Not Found"
[notFoundSubtitle]
other = "This page does not exist."
[searchTitle]
other = "Search"
[searchPlaceholder]
other = "Type something..."
[searchResultTitle]
other = "#PAGES_COUNT pages (#TIME_SECONDS seconds)"
[footerBuiltWith]
other = "Built with {{ .Generator }}"
[footerDesignedBy]
other = "Theme {{ .Theme }} designed by {{ .DesignedBy }}"

42
i18n/en.yaml Normal file
View File

@ -0,0 +1,42 @@
toggleMenu:
other: Toggle Menu
archives:
categories:
other: Categories
article:
relatedContents:
other: Related contents
lastUpdatedOn:
other: Last updated on
notFound:
title:
other: Not Found
subtitle:
other: This page does not exist.
widget:
archives:
title:
other: Archives
more:
other: More
tagCloud:
title:
other: Tags
search:
title:
other: Search
placeholder:
other: Type something...
resultTitle:
other: "#PAGES_COUNT pages (#TIME_SECONDS seconds)"
footer:
builtWith:
other: "Built with {{ .Generator }}"
designedBy:
other: "Theme {{ .Theme }} designed by {{ .DesignedBy }}"

View File

@ -1,7 +1,7 @@
{{ define "main" }}
<div class="not-found-card">
<h1 class="article-title">{{ T "notFoundTitle" }}</h1>
<h2 class="article-subtitle">{{ T "notFoundSubtitle" }}</h2>
<h1 class="article-title">{{ T "notFound.title" }}</h1>
<h2 class="article-subtitle">{{ T "notFound.subtitle" }}</h2>
</div>
{{ partialCached "footer/footer" . }}
{{ end }}

View File

@ -2,7 +2,7 @@
{{ define "main" }}
{{ $categories := ($.Site.GetPage "taxonomyTerm" "categories").Pages }}
{{ if $categories }}
<h2 class="section-title">{{ T "categoriesTitle" }}</h2>
<h2 class="section-title">{{ T "archives.categories" }}</h2>
<div class="category-list">
<div class="article-list--tile">
{{ range $categories }}

View File

@ -7,8 +7,8 @@
{{ define "main" }}
<form action="{{ .Permalink }}" class="search-form"{{ with .OutputFormats.Get "json" -}} data-json="{{ .Permalink }}"{{- end }}>
<p>
<label>{{ T "searchTitle" }}</label>
<input name="keyword" placeholder="{{ T `searchPlaceholder` }}" />
<label>{{ T "search.title" }}</label>
<input name="keyword" placeholder="{{ T `search.placeholder` }}" />
</p>
<button title="Search">
@ -20,7 +20,7 @@
<div class="search-result--list article-list--compact"></div>
<script>
window.searchResultTitleTemplate = "{{ T `searchResultTitle` }}"
window.searchResultTitleTemplate = "{{ T `search.resultTitle` }}"
</script>
{{- $opts := dict "minify" hugo.IsProduction "JSXFactory" "createElement" -}}

View File

@ -12,7 +12,7 @@
<section class="article-time">
{{ partial "helper/icon" "clock" }}
<span class="article-time--modified">
{{ T "lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat.lastUpdated "Jan 02, 2006 15:04 MST" ) }}
{{ T "article.lastUpdatedOn" }} {{ .Lastmod.Format ( or .Site.Params.dateFormat.lastUpdated "Jan 02, 2006 15:04 MST" ) }}
</span>
</section>
{{- end -}}

View File

@ -1,7 +1,7 @@
<aside class="related-contents--wrapper">
{{ $related := (where (.Site.RegularPages.Related .) "Params.hidden" "!=" true) | first 5 }}
{{ with $related }}
<h2 class="section-title">{{ T "relatedContents" }}</h2>
<h2 class="section-title">{{ T "article.relatedContents" }}</h2>
<div class="related-contents">
<div class="flex article-list--tile">
{{ range . }}

View File

@ -6,7 +6,7 @@
{{- $Theme := printf `<b><a href="https://github.com/CaiJimmy/hugo-theme-stack" target="_blank" rel="noopener" data-version="%s">Stack</a></b>` $ThemeVersion -}}
{{- $DesignedBy := `<a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a>` -}}
{{ T "footerBuiltWith" (dict "Generator" $Generator) | safeHTML }} <br />
{{ T "footerDesignedBy" (dict "Theme" $Theme "DesignedBy" $DesignedBy) | safeHTML }}
{{ T "footer.builtWith" (dict "Generator" $Generator) | safeHTML }} <br />
{{ T "footer.designedBy" (dict "Theme" $Theme "DesignedBy" $DesignedBy) | safeHTML }}
</section>
</footer>

View File

@ -2,7 +2,7 @@
<div class="widget-icon">
{{ partial "helper/icon" "infinity" }}
</div>
<h2 class="widget-title section-title">{{ T "widgetArchivesTitle" }}</h2>
<h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2>
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
@ -15,7 +15,7 @@
<div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
{{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="year">{{ T "widgetArchivesMore" }}</span>
<span class="year">{{ T "widget.archives.more" }}</span>
{{ else }}
<span class="year">{{ .Key }}</span>
<span class="count">{{ len $item.Pages }}</span>

View File

@ -1,7 +1,7 @@
<form action="/search" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
<p>
<label>{{ T "searchTitle" }}</label>
<input name="keyword" required placeholder="{{ T `searchPlaceholder` }}" />
<label>{{ T "search.title" }}</label>
<input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
<button title="Search">
{{ partial "helper/icon" "search" }}

View File

@ -2,7 +2,7 @@
<div class="widget-icon">
{{ partial "helper/icon" "tag" }}
</div>
<h2 class="widget-title section-title">{{ T "widgetTagCloudTitle" }}</h2>
<h2 class="widget-title section-title">{{ T "widget.tagCloud.title" }}</h2>
<div class="tagCloud-tags">
{{ range first .Site.Params.widgets.tagCloud.limit .Site.Taxonomies.tags.ByCount }}