From 008add1432a8d768d6cb8a417a4dc2d9be628a59 Mon Sep 17 00:00:00 2001 From: Kevin Matsubara Date: Mon, 22 Dec 2025 21:35:37 +0100 Subject: [PATCH] Use language specific strings in navbar text. --- portfolio/site.hs | 23 ++++++++++++++++++++++- portfolio/templates/index.html | 8 ++++---- portfolio/templates/navbar.html | 8 ++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/portfolio/site.hs b/portfolio/site.hs index 6e6b851..4842378 100644 --- a/portfolio/site.hs +++ b/portfolio/site.hs @@ -25,7 +25,7 @@ main = hakyll $ do match (fromList ["about.rst", "contact.markdown"]) $ do route $ setExtension "html" compile $ pandocCompiler - >>= loadAndApplyTemplate "templates/default.html" defaultContext + >>= loadAndApplyTemplate "templates/default.html" staticPageContext >>= relativizeUrls match "posts/*" $ do @@ -57,6 +57,7 @@ main = hakyll $ do listField "posts" postCtx (return posts) `mappend` constField "title" "Archives" `mappend` constField "language" "en" `mappend` + langDict "en" <> defaultContext makeItem "" @@ -73,6 +74,7 @@ main = hakyll $ do constField "title" "Plamo" `mappend` constField "logosub" "Plamo enthousiast" `mappend` constField "language" "en" `mappend` + langDict "en" <> defaultContext makeItem "" @@ -116,9 +118,16 @@ main = hakyll $ do -------------------------------------------------------------------------------- +staticPageContext :: Context String +staticPageContext = + langDict "en" <> + defaultContext + postCtx :: Context String postCtx = dateField "date" "%e %B %Y" `mappend` + constField "language" "en" `mappend` + langDict "en" <> defaultContext isUpcoming :: UTCTime -> Item a -> Compiler Bool @@ -135,16 +144,28 @@ langDict :: String -> Context a langDict "nl" = constField "welcome" "Welkom" <> constField "switcher" "Taal" <> + constField "title-japan" "Japan" <> + constField "title-plamo" "Plamo" <> + constField "title-radio" "Radio" <> + constField "title-software" "Software" <> mempty langDict "jp" = constField "welcome" "ようこそ" <> constField "switcher" "言語" <> + constField "title-japan" "日本" <> + constField "title-plamo" "プラモ" <> + constField "title-radio" "ラジオ" <> + constField "title-software" "ソフトウェア" <> mempty langDict "en" = constField "welcome" "Welcome" <> constField "switcher" "Language" <> + constField "title-japan" "Japan" <> + constField "title-plamo" "Plamo" <> + constField "title-radio" "Radio" <> + constField "title-software" "Software" <> mempty langDict _ = mempty diff --git a/portfolio/templates/index.html b/portfolio/templates/index.html index 9f54f4b..9856dce 100644 --- a/portfolio/templates/index.html +++ b/portfolio/templates/index.html @@ -17,7 +17,7 @@ thumbnail
-

Japan

+

$title-japan$

@@ -29,7 +29,7 @@ thumbnail
-

Plamo

+

$title-plamo$

@@ -41,7 +41,7 @@ thumbnail
-

Radio

+

$title-radio$

@@ -53,7 +53,7 @@ thumbnail
-

Software

+

$title-software$

diff --git a/portfolio/templates/navbar.html b/portfolio/templates/navbar.html index ab320d5..fcc9a29 100644 --- a/portfolio/templates/navbar.html +++ b/portfolio/templates/navbar.html @@ -9,16 +9,16 @@