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" baseURL = "https://log101.github.io"
languageCode = "en-us" languageCode = "tr"
defaultContentLanguage = "en" defaultContentLanguage = "tr"
title = "log101" title = "log101"
theme = "hermit" theme = "hermit"
# enableGitInfo = true # enableGitInfo = true
@ -10,6 +10,23 @@ pygmentsUseClasses = true
rssLimit = 10 # Maximum number of items in the RSS feed. rssLimit = 10 # Maximum number of items in the RSS feed.
enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/functions/emojify/ 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] [author]
name = "Furkan Erdem" name = "Furkan Erdem"
@ -51,26 +68,35 @@ enableEmoji = true # Shorthand emojis in content files - https://gohugo.io/func
[menu] [menu]
[[menu.main]] [[menu.main]]
name = "Posts" identifier = 'posts'
name = "Yazılar"
url = "posts/" url = "posts/"
weight = 10 weight = 10
[[menu.main]] [[menu.main]]
name = "Github" identifier = 'projects'
url = "about-hugo/" name = "Projeler"
url = "about/"
weight = 20 weight = 20
[[menu.main]] [[menu.main]]
name = "CV" name = "Github"
url = "about-hugo/" url = "about/"
weight = 30 weight = 30
[[menu.main]] [[menu.main]]
name = "Stories" name = "CV"
url = "about-hugo/" url = "about/"
weight = 40 weight = 40
[[menu.main]] [[menu.main]]
name = "Running" identifier = 'stories'
url = "about-hugo/" name = "Hikayeler"
url = "about/"
weight = 50 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 }} {{- range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | absURL }}"> <link rel="stylesheet" href="{{ . | absURL }}">
{{- end }} {{- 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" -}} {{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }} {{ partial "extra-head.html" . }}
{{- end }} {{- end }}

View File

@ -21,6 +21,13 @@
</nav> </nav>
</div> </div>
<div id="home-footer"> <div id="home-footer">
{{ if .IsTranslated }}
<nav class="LangNav">
{{ range .Translations }}
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end}}
</nav>
{{ end }}
<p> <p>
&copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a>{{ .Site.Params.footerCopyright | safeHTML }} &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 }} {{- 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 }} {{- range .Site.Menus.main }}
{{- if .HasChildren }} {{- 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"> <span class="sub-menu">
{{- range .Children }} {{- range .Children }}
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a> <a href="{{ .URL | absLangURL }}">{{ or (T .Identifier) .Name | safeHTML }}</a>
{{- end }} {{- end }}
</span> </span>
{{- else }} {{- else }}
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a> <a href="{{ .URL | absLangURL }}">{{ or (T .Identifier) .Name | safeHTML }}</a>
{{- end }} {{- end }}
{{- end }} {{- end }}