From 2ce657fe5e10b7ac9a6cc6eb9d8fd7b27713770c Mon Sep 17 00:00:00 2001 From: SJost Date: Wed, 27 Feb 2019 11:22:45 +0100 Subject: [PATCH] stub for i18nWidgetFile created and used --- models/users | 1 + src/Handler/Home.hs | 7 +++---- src/Handler/Utils.hs | 12 ++++++++++++ .../de.hamlet} | 2 +- templates/{impressum.hamlet => imprint/de.hamlet} | 0 .../{infoLecturer.hamlet => info-lecturer/de.hamlet} | 0 6 files changed, 17 insertions(+), 5 deletions(-) rename templates/{data-protection-de.hamlet => data-protection/de.hamlet} (99%) rename templates/{impressum.hamlet => imprint/de.hamlet} (100%) rename templates/{infoLecturer.hamlet => info-lecturer/de.hamlet} (100%) diff --git a/models/users b/models/users index 5ac4a6a3c..bddb5c4a8 100644 --- a/models/users +++ b/models/users @@ -1,3 +1,4 @@ +-- Some comments needes User json ident (CI Text) authentication AuthenticationMode diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index 6363b641a..b9579f26d 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -192,7 +192,7 @@ getImpressumR :: Handler Html getImpressumR = -- do siteLayoutMsg' MsgMenuImpressum $ do setTitleI MsgImpressumHeading - $(widgetFile "impressum") + $(i18nWidgetFile "imprint") -- | Hinweise zu Datenschutz und Aufbewahrungspflichten @@ -200,7 +200,7 @@ getDataProtR :: Handler Html getDataProtR = -- do siteLayoutMsg' MsgMenuDataProt $ do setTitleI MsgDataProtHeading - $(widgetFile "data-protection-de") + $(i18nWidgetFile "data-protection") -- | Allgemeine Informationen @@ -280,8 +280,7 @@ getInfoLecturerR :: Handler Html getInfoLecturerR = siteLayoutMsg' MsgInfoLecturerTitle $ do setTitleI MsgInfoLecturerTitle - -- TODO: Translation. This is simply too much for a simple message and too akwward to cut into bits. Create i18nWidgetFile tool. - $(widgetFile "infoLecturer") + $(i18nWidgetFile "info-lecturer") getAuthPredsR, postAuthPredsR :: Handler Html diff --git a/src/Handler/Utils.hs b/src/Handler/Utils.hs index 67beeabd1..ca32ba574 100644 --- a/src/Handler/Utils.hs +++ b/src/Handler/Utils.hs @@ -8,6 +8,9 @@ import qualified Data.Text as T -- import qualified Data.Set (Set) import qualified Data.Set as Set +import Language.Haskell.TH (Q, Exp) +-- import Language.Haskell.TH.Datatype + import Handler.Utils.DateTime as Handler.Utils import Handler.Utils.Form as Handler.Utils import Handler.Utils.Table as Handler.Utils @@ -70,3 +73,12 @@ warnTermDays tid times = do forM_ outoflecture $ warnI MsgDayIsOutOfLecture forM_ outoftermdays $ warnI MsgDayIsOutOfTerm +-- | Add language dependent template files +-- For large files which are translated as a whole. +-- Argument musst be a directory under templates, +-- which contains a file for each language, +-- eg. /templates/imprint/de.hamlet and /templates/imprint/en.hamlet +i18nWidgetFile :: FilePath -> Q Exp +i18nWidgetFile = + -- TODO write code to distinguish languages here + widgetFile . ( "de") \ No newline at end of file diff --git a/templates/data-protection-de.hamlet b/templates/data-protection/de.hamlet similarity index 99% rename from templates/data-protection-de.hamlet rename to templates/data-protection/de.hamlet index f65090713..8158b4709 100644 --- a/templates/data-protection-de.hamlet +++ b/templates/data-protection/de.hamlet @@ -73,7 +73,7 @@

Welche Daten werden erhoben Der Webserver protokolliert