feat: add i18n, add en, translate menus

This commit is contained in:
log101 2023-12-06 03:42:08 +00:00
parent 069362247e
commit 59128dfbc6
7 changed files with 64 additions and 14 deletions

View File

@ -1,6 +1,6 @@
baseURL = "https://log101.github.io"
languageCode = "en-us"
defaultContentLanguage = "en"
languageCode = "tr"
defaultContentLanguage = "tr"
title = "log101"
theme = "hermit"
# enableGitInfo = true
@ -10,6 +10,23 @@ pygmentsUseClasses = true
rssLimit = 10 # Maximum number of items in the RSS feed.
enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/functions/emojify/
[languages]
[languages.tr]
disabled = false
languageCode = 'tr'
languageDirection = 'ltr'
languageName = 'Turkish'
title = 'Log101'
weight = 10
[languages.en]
disabled = false
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Log101'
weight = 20
[author]
name = "Furkan Erdem"
@ -51,26 +68,35 @@ enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/func
[menu]
[[menu.main]]
name = "Posts"
identifier = 'posts'
name = "Yazılar"
url = "posts/"
weight = 10
[[menu.main]]
name = "Github"
url = "about-hugo/"
identifier = 'projects'
name = "Projeler"
url = "about/"
weight = 20
[[menu.main]]
name = "CV"
url = "about-hugo/"
name = "Github"
url = "about/"
weight = 30
[[menu.main]]
name = "Stories"
url = "about-hugo/"
name = "CV"
url = "about/"
weight = 40
[[menu.main]]
name = "Running"
url = "about-hugo/"
identifier = 'stories'
name = "Hikayeler"
url = "about/"
weight = 50
[[menu.main]]
identifier = 'running'
name = "Koşu"
url = "about/"
weight = 60

1
content/about.en.md Normal file
View File

@ -0,0 +1 @@
About me

1
content/about.tr.md Normal file
View File

@ -0,0 +1 @@
Hakkımda

10
i18n/en.yaml Normal file
View File

@ -0,0 +1,10 @@
- id: about
translation: "About"
- id: posts
translation: "Posts"
- id: projects
translation: "Projects"
- id: stories
translation: "Stories"
- id: running
translation: "Running"

View File

@ -21,6 +21,11 @@
{{- range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}
{{ if .IsTranslated }}
{{ range .Translations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" title="{{ .Language.LanguageName }}">
{{ end }}
{{ end }}
{{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }}
{{- end }}

View File

@ -21,6 +21,13 @@
</nav>
</div>
<div id="home-footer">
{{ if .IsTranslated }}
<nav class="LangNav">
{{ range .Translations }}
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end}}
</nav>
{{ end }}
<p>
&copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a>{{ .Site.Params.footerCopyright | safeHTML }}
{{- with (not (in (.Site.Language.Get "disableKinds") "RSS")) }} &#183; <a href="{{ "posts/index.xml" | absLangURL }}" target="_blank" title="rss"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"><path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle></svg></a>{{ end }}

View File

@ -1,12 +1,12 @@
{{- range .Site.Menus.main }}
{{- if .HasChildren }}
<a href="{{ .URL | absLangURL }}" class="has-children">{{ .Name }}</a>
<a href="{{ .URL | absLangURL }}" class="has-children">{{ or (T .Identifier) .Name | safeHTML }}</a>
<span class="sub-menu">
{{- range .Children }}
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
<a href="{{ .URL | absLangURL }}">{{ or (T .Identifier) .Name | safeHTML }}</a>
{{- end }}
</span>
{{- else }}
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
<a href="{{ .URL | absLangURL }}">{{ or (T .Identifier) .Name | safeHTML }}</a>
{{- end }}
{{- end }}