Play around with translations

This commit is contained in:
Joshua Goins 2024-10-13 18:50:41 -04:00
parent fbc1c6cd4d
commit b6a9fddc65
17 changed files with 223 additions and 25 deletions

View file

@ -1,10 +1,8 @@
baseURL: 'https://redstrate.com/' baseURL: 'https://redstrate.com/'
copyright: 'This content is licensed under a Creative Commons Attribution-ShareAlike 4.0.' copyright: 'This content is licensed under a Creative Commons Attribution-ShareAlike 4.0.'
defaultContentLanguage: 'en'
disableHugoGeneratorInject: true disableHugoGeneratorInject: true
enableGitInfo: true enableGitInfo: true
enableRobotsTXT: true enableRobotsTXT: true
languageCode: 'en-us'
summarylength: 15 summarylength: 15
disableKinds: disableKinds:
- taxonomy - taxonomy
@ -60,32 +58,32 @@ menu:
- name: 'Home' - name: 'Home'
params: params:
- img: 'icons/home.svg' - img: 'icons/home.svg'
url: '/' url: ''
weight: -1 weight: -1
- name: 'Blog' - name: 'Blog'
params: params:
- img: 'icons/blog.svg' - img: 'icons/blog.svg'
url: '/blog' url: 'blog'
weight: 1 weight: 1
- name: 'Art' - name: 'Art'
params: params:
- img: 'icons/art.svg' - img: 'icons/art.svg'
url: '/art' url: 'art'
weight: 2 weight: 2
- name: 'Music' - name: 'Music'
params: params:
- img: 'icons/music.svg' - img: 'icons/music.svg'
url: '/music' url: 'music'
weight: 3 weight: 3
- name: 'Software' - name: 'Software'
params: params:
- img: 'icons/software.svg' - img: 'icons/software.svg'
url: '/software' url: 'software'
weight: 4 weight: 4
- name: 'Talks' - name: 'Talks'
params: params:
- img: 'icons/talks.svg' - img: 'icons/talks.svg'
url: '/talks' url: 'talks'
weight: 5 weight: 5
- name: 'Games' - name: 'Games'
params: params:
@ -100,37 +98,37 @@ menu:
- name: 'Shrines' - name: 'Shrines'
params: params:
- img: 'icons/shrines.svg' - img: 'icons/shrines.svg'
url: '/shrines' url: 'shrines'
weight: 8 weight: 8
- name: 'Links' - name: 'Links'
params: params:
- img: 'icons/links.svg' - img: 'icons/links.svg'
url: '/links' url: 'links'
weight: 9 weight: 9
- name: 'Guestbook' - name: 'Guestbook'
params: params:
- img: 'icons/guestbook.svg' - img: 'icons/guestbook.svg'
url: '/guestbook' url: 'guestbook'
weight: 10 weight: 10
- name: 'Contact' - name: 'Contact'
params: params:
- img: 'icons/contact.svg' - img: 'icons/contact.svg'
url: '/contact' url: 'contact'
weight: 11 weight: 11
- name: 'About' - name: 'About'
params: params:
- img: 'icons/about.svg' - img: 'icons/about.svg'
url: '/about' url: 'about'
weight: 12 weight: 12
footer: footer:
- name: 'Feeds' - name: 'Feeds'
url: '/feeds' url: 'feeds'
weight: -1 weight: -1
- name: 'Imprint' - name: 'Imprint'
url: '/imprint' url: 'imprint'
weight: 2 weight: 2
- name: 'Accessibility' - name: 'Accessibility'
url: '/accessibility' url: 'accessibility'
weight: 3 weight: 3
badges: badges:
- name: 'CC NC SA' - name: 'CC NC SA'
@ -190,3 +188,39 @@ menu:
- img: 'kofi.webp' - img: 'kofi.webp'
url: 'https://ko-fi.com/redstrate' url: 'https://ko-fi.com/redstrate'
weight: 4 weight: 4
defaultContentLanguage: 'en'
languageCode: 'en-us'
defaultContentLanguageInSubdir: false
languages:
en:
languageName: English
tok:
contentDir: content/tok
languageName: Toki Pona
disabled: true
de:
contentDir: content/de
languageName: German
disabled: true
jp:
languageName: Japanese
menus:
main:
- name: 'トップ'
params:
- img: 'icons/home.svg'
url: ''
weight: -1
- name: '芸術'
params:
- img: 'icons/art.svg'
url: 'art'
weight: 2
socials:
- name: 'pixiv'
params:
- img: 'pixiv.webp'
url: 'https://www.pixiv.net/en/users/58118005'
weight: 2

5
content/_index.jp.md Normal file
View file

@ -0,0 +1,5 @@
---
title: "Home"
---
進行中...

View file

@ -0,0 +1,103 @@
{{ $sizes := unmarshal (readFile "/data/sizes.json") }}
{{ range readDir "/data/art" }}
{{ if .IsDir }}
{{ $year := .Name }}
{{ range readDir ( printf "/data/art/%s" .Name ) }}
{{ if eq (path.Ext .Name) ".json" }}
{{ $file := readFile ( printf "/data/art/%s/%s" $year .Name ) }}
{{ $data := unmarshal $file }}
{{ $basename := strings.TrimSuffix (path.Ext .Name) .Name }}
{{ $content := dict
"mediaType" "text/markdown"
"value" $data.description
}}
{{ $split := split $data.date "-" }}
{{ $split_len := $split | len }}
{{ $dates := dict "date" (time.Now) }}
{{ $exclude_feed := false }}
{{ if gt $split_len 1 }}
{{ $dates = dict "date" (time.AsTime $data.date) }}
{{ else }}
{{ $dates = dict "date" (time.AsTime (printf "%s-01-01" $data.date)) }}
{{ $exclude_feed = true }}
{{ end }}
{{ $title := "Untitled Artwork" }}
{{ with $data.title }}
{{ $title = . }}
{{ end }}
{{ $params := dict
"slug" $basename
"alt_text" $data.alt_text
"artist" $data.artist
"excludefeed" $exclude_feed
"arttags" $data.tags
"characters" $data.characters
"nsfw" $data.nsfw
"mastodon_url" $data.mastodon_url
"pixiv_url" $data.pixiv_url
"newgrounds_url" $data.newgrounds_url
"program" $data.program
"guest" (eq $year "guest")
"threed" (eq $data.type "3D")
"animation" (eq $data.type "Animation")
"orbit" (index $data "camera-orbit")
"target" (index $data "camera-target")
"fov" (index $data "camera-fov")
"comic" (eq $data.type "Comic")
"pages" $data.pages
"width" (index $sizes.full $basename).width
"height" (index $sizes.full $basename).height
"thumb_width" (index $sizes.thumb $basename).width
"thumb_height" (index $sizes.thumb $basename).height
}}
{{ $path := $basename }}
{{ if eq $year "guest" }}
{{ $path = (printf "guest/%s" $basename) }}
{{ end }}
{{ $languages := $data.languages }}
{{ range $key, $val := $languages }}
{{/* This is needed because art is placed under a different URL based on permalinks, and those aren't localized. */}}
{{ $month := "1" }}
{{ $year := "1" }}
{{ if $data.date }}
{{ $split := split $data.date "-" }}
{{ $month = index $split 1 }}
{{ $year = index $split 0 }}
{{ end }}
{{ $langPage := dict
"slug" $basename
"content" $content
"dates" $dates
"kind" "page"
"path" $path
"title" $val.title
"params" $params
"layout" "art-detail"
}}
{{ warnf $langPage.path }}
{{ $.AddPage $langPage }}
{{ end }}
{{ end }}
{{ end }}
{{ if not (eq $year "guest") }}
{{ $page := dict
"slug" $year
"kind" "section"
"path" $year
"title" $year
"layout" "year-gallery"
}}
{{ $.AddPage $page }}
{{ end }}
{{ end }}
{{ end }}

5
content/art/_index.jp.md Normal file
View file

@ -0,0 +1,5 @@
---
title: "芸術"
---
進行中...

View file

7
content/de/index.md Normal file
View file

@ -0,0 +1,7 @@
---
title: "Haus"
---
Hallo! Das ist mein Website, und meine name ist **redstrate**. Ich bin nicht gut in übersetzen Englisch, Entschuldigung!
TODO...

9
content/tok/index.md Normal file
View file

@ -0,0 +1,9 @@
---
title: "tomo"
---
{{< insert-pic "pic-home.webp" "Drawing of a landscape bathed in sunlight. There's a small cottage in the middle of green hills." >}}
mi jo e ma. nimi mi li **redstrate**. mi pali e toki pona. mi pali e ma.
TODO...

View file

@ -8,5 +8,10 @@
"characters": [ "characters": [
"Merume" "Merume"
], ],
"title": "Another Thursday" "title": "Another Thursday",
"languages": {
"jp": {
"title": "めるめ外出!"
}
}
} }

5
i18n/en.yaml Normal file
View file

@ -0,0 +1,5 @@
navigation: Navigation
social_media: Accounts
date: Date
characters: Characters
program: Program

5
i18n/jp.yaml Normal file
View file

@ -0,0 +1,5 @@
navigation: グロナビ
social_media: ソーシャルメディア
date:
characters: 作中人物
program: ソフトウェア

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -53,7 +53,7 @@
<table> <table>
<tr> <tr>
<th>Date</th> <th>{{ i18n "date" }}</th>
<td> <td>
<time datetime="{{ .Page.Lastmod.Format "2006-01-02" }}" class="text-muted"> <time datetime="{{ .Page.Lastmod.Format "2006-01-02" }}" class="text-muted">
{{ $.Date.Format "January 2006" }} {{ $.Date.Format "January 2006" }}
@ -63,7 +63,7 @@
{{ with .Params.arttags }} {{ with .Params.arttags }}
<tr> <tr>
<th>Tags</th> <th>{{ i18n "tags" }}</th>
<td> <td>
{{ $len := (len .) }} {{ $len := (len .) }}
{{ range $index, $element := . }} {{ range $index, $element := . }}
@ -75,7 +75,7 @@
{{ with .Params.characters }} {{ with .Params.characters }}
<tr> <tr>
<th>Characters</th> <th>{{ i18n "characters" }}</th>
<td> <td>
{{ $len := (len .) }} {{ $len := (len .) }}
{{ range $index, $element := . }} {{ range $index, $element := . }}

View file

@ -1,6 +1,6 @@
{{/* Partial used to display a grid of artwork. */}} {{/* Partial used to display a grid of artwork. */}}
{{ $paginator := .Paginate (where .RegularPagesRecursive "Type" "art") }} {{ $paginator := .Paginate (where $.Site.Pages "Type" "art") }}
{{ template "_internal/pagination.html" . }} {{ template "_internal/pagination.html" . }}
{{ $on_guest := eq .Title "Guest Art" }} {{ $on_guest := eq .Title "Guest Art" }}

View file

@ -3,7 +3,7 @@
<div class="generic-con year-con"> <div class="generic-con year-con">
{{ range (where .Site.RegularPages "Type" "in" "art").GroupByDate "2006" }} {{ range (where .Site.RegularPages "Type" "in" "art").GroupByDate "2006" }}
{{ with .Key }} {{ with .Key }}
<a class="no-decoration" href="/art/{{ . }}"> <a class="no-decoration" href="art/{{ . }}">
{{ $thumbp := printf "%s/year-thumbs/%s.webp" $.Site.Params.image_host . }} {{ $thumbp := printf "%s/year-thumbs/%s.webp" $.Site.Params.image_host . }}
<img width="256" height="128" title="{{ . }}" alt="A thumbnail of {{ . }}'s art with the text in the center." class="gallery-img article-img" src="{{ $thumbp }}"> <img width="256" height="128" title="{{ . }}" alt="A thumbnail of {{ . }}'s art with the text in the center." class="gallery-img article-img" src="{{ $thumbp }}">
</a> </a>

View file

@ -2,7 +2,7 @@
<details id="nav-menu" open> <details id="nav-menu" open>
<summary>Menu</summary> <summary>Menu</summary>
<strong>Navigation</strong> <strong>{{ lang.Translate "navigation" }}</strong>
{{ $icon := resources.Get "external-link.svg" }} {{ $icon := resources.Get "external-link.svg" }}
@ -11,13 +11,17 @@
{{ with resources.Get .Params.img }} {{ with resources.Get .Params.img }}
<img alt="" class="symbolic-icon" style="image-rendering: pixelated;" width="16" height="16" src="{{ .RelPermalink }}"> <img alt="" class="symbolic-icon" style="image-rendering: pixelated;" width="16" height="16" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
<a href="{{ .URL }}">{{ .Name }}{{ if strings.HasPrefix .URL "http" }}<img class="external-link" aria-hidden="true" alt="External link" width="16" height="16" src="{{ $icon.RelPermalink }}">{{- end -}}</a> {{ $url := .URL }}
{{ if not (strings.Contains $url "https") }}
{{ $url = printf "%s%s" $.Site.Home.Permalink .URL }}
{{ end }}
<a href="{{ $url }}">{{ .Name }}{{ if strings.HasPrefix .URL "http" }}<img class="external-link" aria-hidden="true" alt="External link" width="16" height="16" src="{{ $icon.RelPermalink }}">{{- end -}}</a>
</div> </div>
{{ end }} {{ end }}
<br/> <br/>
<strong>Accounts</strong> <strong>{{ lang.Translate "social_media" }}</strong>
{{ range .Site.Menus.socials }} {{ range .Site.Menus.socials }}
<div class="site-menu"> <div class="site-menu">
@ -27,5 +31,21 @@
<a rel="me" href="{{ .URL }}">{{ .Name }}{{ if strings.HasPrefix .URL "http" }}<img class="external-link" aria-hidden="true" alt="External link" width="16" height="16" src="{{ $icon.RelPermalink }}">{{- end -}}</a> <a rel="me" href="{{ .URL }}">{{ .Name }}{{ if strings.HasPrefix .URL "http" }}<img class="external-link" aria-hidden="true" alt="External link" width="16" height="16" src="{{ $icon.RelPermalink }}">{{- end -}}</a>
</div> </div>
{{ end }} {{ end }}
{{ if .IsTranslated }}
<br>
<strong>Available Languages</strong>
<div class="site-meni">
{{ $currentPage := . }}
{{ range .Translations }}
{{ $specificLang := .Lang }}
{{ range $currentPage.Translations }}
{{ if (eq .Lang $specificLang) }}
<a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}
{{ end }}
</div>
{{ end }}
</details> </details>
</nav> </nav>