feat(i18n): add translations for the new languages (de, es, fr, it, CJK)

This commit is contained in:
Sped0n
2023-11-03 14:19:06 +08:00
parent e2861aa645
commit f4eda42785
19 changed files with 137 additions and 17 deletions

View File

@@ -17,7 +17,7 @@ body {
}
}
body:lang(en) {
body:lang(en, de, es, fr, it) {
font-family: 'Geist', sans-serif;
}

View File

@@ -15,23 +15,24 @@ type NavItem = (typeof navItems)[number]
* variables
*/
const navItems = ['prev', 'close', 'next'] as const
const mainDiv = document.getElementById('main') as HTMLDivElement
const navItems = [
mainDiv.getAttribute('prevText') as string,
mainDiv.getAttribute('closeText') as string,
mainDiv.getAttribute('nextText') as string
] as const
/**
* main functions
*/
function handleClick(type: NavItem): void {
switch (type) {
case 'prev':
prevImage()
break
case 'close':
minimizeImage()
break
case 'next':
nextImage()
break
if (type === navItems[0]) {
prevImage()
} else if (type === navItems[1]) {
minimizeImage()
} else {
nextImage()
}
}

View File

@@ -4,7 +4,13 @@ import { type Swiper } from 'swiper'
import { container } from '../container'
import { type ImageJSON } from '../resources'
import { setIndex, state } from '../state'
import { Watchable, expand, loadGsap, loadSwiper } from '../utils'
import {
Watchable,
capitalizeFirstLetter,
expand,
loadGsap,
loadSwiper
} from '../utils'
import { mounted } from './mounted'
import { scrollable } from './scroll'
@@ -214,7 +220,10 @@ function createGallery(ijs: ImageJSON[]): void {
)
// close
const _close = document.createElement('div')
_close.innerText = 'Close'
const str: string = document
.getElementById('main')
?.getAttribute('closeText') as string
_close.innerText = capitalizeFirstLetter(str)
_close.addEventListener(
'click',
() => {

View File

@@ -12,6 +12,10 @@ disableKinds = ["section", "taxonomy", "term", "home"]
enableRobotsTXT = true
# available options
# * en (powered by Geist)
# * de (powered by Geist)
# * es (powered by Geist)
# * fr (powered by Geist)
# * it (powered by Geist)
# * zh-sg zh-cn (powered by Noto Sans SC)
# * zh-hk zh-tw zh-mo (powered by Noto Sans TC)
# * ja (powered by Noto Sans JP)

9
i18n/de.toml Normal file
View File

@@ -0,0 +1,9 @@
[next]
other = "nächste"
[prev]
other = "vorher"
[close]
other = "schließen"
# capititalized for menu
[threshold]
other = "Schwelle"

9
i18n/en.toml Normal file
View File

@@ -0,0 +1,9 @@
[next]
other = "next"
[prev]
other = "prev"
[close]
other = "close"
# capitialize the first letter of the word
[threshold]
other = "Threshold"

9
i18n/es.toml Normal file
View File

@@ -0,0 +1,9 @@
[next]
other = "siguiente"
[prev]
other = "previo"
[close]
other = "cerrar"
# capititalized for menu
[threshold]
other = "Umbral"

9
i18n/fr.toml Normal file
View File

@@ -0,0 +1,9 @@
[next]
other = "suivant"
[prev]
other = "précédent"
[close]
other = "fermer"
# capititalized for menu
[threshold]
other = "Seuil"

9
i18n/it.toml Normal file
View File

@@ -0,0 +1,9 @@
[next]
other = "prossimo"
[prev]
other = "precedente"
[close]
other = "chiudi"
# capititalized for menu
[threshold]
other = "Soglia"

8
i18n/ja.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "進む"
[prev]
other = "後退"
[close]
other = "閉じる"
[threshold]
other = "しきい値"

8
i18n/ko.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "전진"
[prev]
other = "물러나세요"
[close]
other = "닫기"
[threshold]
other = "임계값"

8
i18n/zh-cn.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "前进"
[prev]
other = "后退"
[close]
other = "关闭"
[threshold]
other = "阈值"

8
i18n/zh-hk.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "前進"
[prev]
other = "後退"
[close]
other = "關閉"
[threshold]
other = "閾值"

8
i18n/zh-mo.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "前進"
[prev]
other = "後退"
[close]
other = "關閉"
[threshold]
other = "閾值"

8
i18n/zh-sg.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "前进"
[prev]
other = "后退"
[close]
other = "关闭"
[threshold]
other = "阈值"

8
i18n/zh-tw.toml Normal file
View File

@@ -0,0 +1,8 @@
[next]
other = "前進"
[prev]
other = "後退"
[close]
other = "關閉"
[threshold]
other = "閾值"

View File

@@ -3,7 +3,12 @@
{{- $currentPage := . -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{- partial "resources/imageJSON.html" (dict "Path" .DirName "Page" $currentPage) -}}
<script>document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")</script>
<script>
document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")
document.getElementById("main").setAttribute("nextText", "{{- i18n "next" -}}")
document.getElementById("main").setAttribute("prevText", "{{- i18n "prev" -}}")
document.getElementById("main").setAttribute("closeText", "{{- i18n "close" -}}")
</script>
{{- end -}}
<div class="container">
{{- partial "nav.html" . -}}

View File

@@ -29,7 +29,7 @@
{{/* fonts */}}
<link rel="preload" href="/lib/fonts/NotoSans-Regular.woff2" as="font" crossorigin />
{{- if (partial "function/langCode.html" (slice "en")) -}}
{{- if (partial "function/langCode.html" (slice "en" "de" "fr" "es" "it")) -}}
<link rel="preload" href="/lib/fonts/GeistVF.woff2" as="font" crossorigin />
{{- else if (partial "function/langCode.html" (slice "zh-cn" "zh-sg")) -}}
<link

View File

@@ -17,7 +17,7 @@
{{- end -}}
</div>
<div class="threshold">
<span>Threshold:</span>
<span>{{- i18n "threshold" -}}:</span>
<span>
<button class="dec">&#xFF0D;</button>
<span class="num"></span><span class="num"></span><span class="num"></span