2023-06-09 09:42:58 +02:00
|
|
|
import qualified System.IO as IO
|
2023-06-08 21:49:35 +02:00
|
|
|
|
|
|
|
import Registry.Utils
|
|
|
|
import Registry.Grammar (registry)
|
|
|
|
import Registry.Registry
|
|
|
|
|
2023-06-12 21:35:43 +02:00
|
|
|
import System.Directory (createDirectoryIfMissing)
|
|
|
|
|
2023-06-08 21:49:35 +02:00
|
|
|
infile = "./language-subtag-registry"
|
|
|
|
outdir = "./registry-html"
|
|
|
|
|
|
|
|
display reg thistype thisvalue =
|
|
|
|
-- We should always retrieve only one value, so we can take the head
|
|
|
|
toHTML ((filter (onlyThisValue thistype thisvalue)
|
|
|
|
(filter (onlyThisType thistype) reg)) !! 0)
|
|
|
|
|
|
|
|
toHTMLFiles reg thetype =
|
|
|
|
mapM (toHTMLfile reg thetype) (filter (onlyThisType thetype) reg)
|
|
|
|
|
|
|
|
toHTMLfile reg thistype thisvalue = do
|
|
|
|
let outfile = outdir ++ "/" ++ thistype ++ "/" ++ (toSubtag thisvalue) ++ ".html"
|
|
|
|
f <- IO.openFile (outfile) IO.WriteMode
|
|
|
|
IO.hPutStr f (display reg thistype (toSubtag thisvalue))
|
|
|
|
IO.hClose f
|
|
|
|
|
|
|
|
foreach [] func = return ()
|
|
|
|
foreach a func = do
|
|
|
|
func (head a)
|
|
|
|
foreach (tail a) func
|
|
|
|
|
|
|
|
main = do
|
|
|
|
f <- IO.openFile (infile) IO.ReadMode
|
|
|
|
input <- IO.hGetContents f
|
|
|
|
let theregistry = getRegistry input
|
|
|
|
foreach ["language", "script", "region", "variant",
|
2023-06-12 21:35:43 +02:00
|
|
|
"redundant", "grandfathered"]
|
|
|
|
(\arg ->
|
|
|
|
createDirectoryIfMissing True (outdir ++ "/" ++ arg) >>
|
|
|
|
toHTMLFiles theregistry arg)
|
2023-06-08 21:49:35 +02:00
|
|
|
|