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" }} {{ define "main" }}
<div class="not-found-card"> <div class="not-found-card">
<h1 class="article-title">{{ T "notFoundTitle" }}</h1> <h1 class="article-title">{{ T "notFound.title" }}</h1>
<h2 class="article-subtitle">{{ T "notFoundSubtitle" }}</h2> <h2 class="article-subtitle">{{ T "notFound.subtitle" }}</h2>
</div> </div>
{{ partialCached "footer/footer" . }} {{ partialCached "footer/footer" . }}
{{ end }} {{ end }}

View File

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

View File

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

View File

@ -12,7 +12,7 @@
<section class="article-time"> <section class="article-time">
{{ partial "helper/icon" "clock" }} {{ partial "helper/icon" "clock" }}
<span class="article-time--modified"> <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> </span>
</section> </section>
{{- end -}} {{- end -}}

View File

@ -1,7 +1,7 @@
<aside class="related-contents--wrapper"> <aside class="related-contents--wrapper">
{{ $related := (where (.Site.RegularPages.Related .) "Params.hidden" "!=" true) | first 5 }} {{ $related := (where (.Site.RegularPages.Related .) "Params.hidden" "!=" true) | first 5 }}
{{ with $related }} {{ with $related }}
<h2 class="section-title">{{ T "relatedContents" }}</h2> <h2 class="section-title">{{ T "article.relatedContents" }}</h2>
<div class="related-contents"> <div class="related-contents">
<div class="flex article-list--tile"> <div class="flex article-list--tile">
{{ range . }} {{ 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 -}} {{- $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>` -}} {{- $DesignedBy := `<a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a>` -}}
{{ T "footerBuiltWith" (dict "Generator" $Generator) | safeHTML }} <br /> {{ T "footer.builtWith" (dict "Generator" $Generator) | safeHTML }} <br />
{{ T "footerDesignedBy" (dict "Theme" $Theme "DesignedBy" $DesignedBy) | safeHTML }} {{ T "footer.designedBy" (dict "Theme" $Theme "DesignedBy" $DesignedBy) | safeHTML }}
</section> </section>
</footer> </footer>

View File

@ -2,7 +2,7 @@
<div class="widget-icon"> <div class="widget-icon">
{{ partial "helper/icon" "infinity" }} {{ partial "helper/icon" "infinity" }}
</div> </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 }} {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
@ -15,7 +15,7 @@
<div class="archives-year"> <div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}"> <a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
{{ if eq $index $.Site.Params.widgets.archives.limit }} {{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="year">{{ T "widgetArchivesMore" }}</span> <span class="year">{{ T "widget.archives.more" }}</span>
{{ else }} {{ else }}
<span class="year">{{ .Key }}</span> <span class="year">{{ .Key }}</span>
<span class="count">{{ len $item.Pages }}</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 }}> <form action="/search" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
<p> <p>
<label>{{ T "searchTitle" }}</label> <label>{{ T "search.title" }}</label>
<input name="keyword" required placeholder="{{ T `searchPlaceholder` }}" /> <input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
<button title="Search"> <button title="Search">
{{ partial "helper/icon" "search" }} {{ partial "helper/icon" "search" }}

View File

@ -2,7 +2,7 @@
<div class="widget-icon"> <div class="widget-icon">
{{ partial "helper/icon" "tag" }} {{ partial "helper/icon" "tag" }}
</div> </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"> <div class="tagCloud-tags">
{{ range first .Site.Params.widgets.tagCloud.limit .Site.Taxonomies.tags.ByCount }} {{ range first .Site.Params.widgets.tagCloud.limit .Site.Taxonomies.tags.ByCount }}