forked from GitHub/gf-rgl
Language list in synopsis is dynamically generated from languages.csv
This commit is contained in:
@@ -11,7 +11,7 @@ S=$(ROOT)/src
|
|||||||
CONFIG=$(ROOT)/languages.csv
|
CONFIG=$(ROOT)/languages.csv
|
||||||
|
|
||||||
# List of languages extracted from languages.csv, with 'Synopsis' column == y
|
# List of languages extracted from languages.csv, with 'Synopsis' column == y
|
||||||
LANGS=$(shell cat $(CONFIG) | cut -d',' -f1,10 | grep ',y' | cut -d',' -f1)
|
LANGS=$(shell cat $(CONFIG) | cut -d',' -f1,11 | grep ',y' | cut -d',' -f1)
|
||||||
|
|
||||||
# This list was constructed by observing what files MkSynopsis.hs reads
|
# This list was constructed by observing what files MkSynopsis.hs reads
|
||||||
SRC_FILES=$(S)/abstract/Common.gf $(S)/abstract/Cat.gf $(S)/api/Constructors.gf $(S)/abstract/Structural.gf $(patsubst %,$S/*/Paradigms%.gf,$(LANGS))
|
SRC_FILES=$(S)/abstract/Common.gf $(S)/abstract/Cat.gf $(S)/api/Constructors.gf $(S)/abstract/Structural.gf $(patsubst %,$S/*/Paradigms%.gf,$(LANGS))
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import MkExxTable
|
import MkExxTable
|
||||||
import System.Process(system)
|
import System.Process(system)
|
||||||
import System.Environment(getArgs)
|
|
||||||
import System.FilePath((</>),(<.>))
|
import System.FilePath((</>),(<.>))
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List
|
import Data.List
|
||||||
@@ -24,19 +23,10 @@ configFile = ".." </> ".." </> Config.configFile
|
|||||||
revealedLang :: String
|
revealedLang :: String
|
||||||
revealedLang = "Eng"
|
revealedLang = "Eng"
|
||||||
|
|
||||||
-- all languages shown (a copy of this list appears in Makefile)
|
|
||||||
apiExxFiles :: IO [FilePath]
|
|
||||||
apiExxFiles = do
|
|
||||||
langs <- loadLangsFrom configFile
|
|
||||||
return $
|
|
||||||
[ "api-examples-" ++ (langCode lang) ++ ".txt"
|
|
||||||
| lang <- langs
|
|
||||||
, langSynopsis lang
|
|
||||||
]
|
|
||||||
|
|
||||||
-- | This function puts together a txt2tags file which is then converted to HTML by the Makefile
|
-- | This function puts together a txt2tags file which is then converted to HTML by the Makefile
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
langs <- loadLangsFrom configFile >>= return . filter langSynopsis
|
||||||
cs1 <- getCats commonAPI
|
cs1 <- getCats commonAPI
|
||||||
cs2 <- getCats catAPI
|
cs2 <- getCats catAPI
|
||||||
let cs = sortCats (cs1 ++ cs2)
|
let cs = sortCats (cs1 ++ cs2)
|
||||||
@@ -50,8 +40,10 @@ main = do
|
|||||||
append "%!postproc(html): '#EUL' '</ul>'"
|
append "%!postproc(html): '#EUL' '</ul>'"
|
||||||
append "%!postproc(html): '#LI' '<li>'"
|
append "%!postproc(html): '#LI' '<li>'"
|
||||||
append "%!postproc(html): '#LParadigms' '<a name=\"RParadigms\"></a>'"
|
append "%!postproc(html): '#LParadigms' '<a name=\"RParadigms\"></a>'"
|
||||||
|
append ("%!postproc(html): '#LANGUAGE_COUNT' '" ++ show (length langs) ++ "'")
|
||||||
|
append ("%!postproc(html): '#LANGUAGES' '" ++ intercalate ", " (map langName langs) ++ ".'")
|
||||||
delimit $ addToolTips cs
|
delimit $ addToolTips cs
|
||||||
include "intro.txt" -- TODO dynamic language list
|
include "intro.txt"
|
||||||
space
|
space
|
||||||
title "Categories"
|
title "Categories"
|
||||||
space
|
space
|
||||||
@@ -72,7 +64,7 @@ main = do
|
|||||||
space
|
space
|
||||||
link "Source 2:" structuralAPI
|
link "Source 2:" structuralAPI
|
||||||
space
|
space
|
||||||
apiExx <- apiExxFiles >>= getApiExx
|
apiExx <- getApiExx (apiExxFiles langs)
|
||||||
rs <- getRules apiExx syntaxAPI
|
rs <- getRules apiExx syntaxAPI
|
||||||
rs2 <- getRules apiExx structuralAPI
|
rs2 <- getRules apiExx structuralAPI
|
||||||
let rss = rs ++ rs2
|
let rss = rs ++ rs2
|
||||||
@@ -87,7 +79,7 @@ main = do
|
|||||||
space
|
space
|
||||||
title "Lexical Paradigms"
|
title "Lexical Paradigms"
|
||||||
append "#LParadigms"
|
append "#LParadigms"
|
||||||
paradigmFiles >>= mapM_ (putParadigms cs)
|
mapM_ (putParadigms cs) (paradigmFiles langs)
|
||||||
space
|
space
|
||||||
include "additional.txt"
|
include "additional.txt"
|
||||||
space
|
space
|
||||||
@@ -242,20 +234,18 @@ catAPI = srcPath "abstract/Cat.gf"
|
|||||||
syntaxAPI = srcPath "api/Constructors.gf"
|
syntaxAPI = srcPath "api/Constructors.gf"
|
||||||
structuralAPI = srcPath "abstract/Structural.gf"
|
structuralAPI = srcPath "abstract/Structural.gf"
|
||||||
|
|
||||||
paradigmFiles :: IO [(String,FilePath)]
|
-- all languages shown (a copy of this list appears in Makefile)
|
||||||
paradigmFiles = do
|
apiExxFiles :: [LangInfo] -> [FilePath]
|
||||||
langs <- loadLangsFrom configFile
|
apiExxFiles langs =
|
||||||
return $
|
[ "api-examples-" ++ (langCode lang) ++ ".txt"
|
||||||
[ (name, srcPath $ printf "%s/Paradigms%s.gf" (langDir lang) (langCode lang))
|
| lang <- langs
|
||||||
| lang <- langs
|
]
|
||||||
, langSynopsis lang
|
|
||||||
, let name = formatName (langDir lang)
|
|
||||||
]
|
|
||||||
|
|
||||||
-- | Format language name from directory name
|
paradigmFiles :: [LangInfo] -> [(String,FilePath)]
|
||||||
-- "ancient_greek -> Ancient Greek"
|
paradigmFiles langs =
|
||||||
formatName :: String -> String
|
[ (langName lang, srcPath $ printf "%s/Paradigms%s.gf" (langDir lang) (langCode lang))
|
||||||
formatName = unwords . map (\(s:ss) -> toUpper s : ss) . splitOn (=='_')
|
| lang <- langs
|
||||||
|
]
|
||||||
|
|
||||||
-- | Split a string at given character, similar to words
|
-- | Split a string at given character, similar to words
|
||||||
splitOn :: (Char -> Bool) -> String -> [String]
|
splitOn :: (Char -> Bool) -> String -> [String]
|
||||||
|
|||||||
@@ -3,41 +3,8 @@
|
|||||||
=Introduction=
|
=Introduction=
|
||||||
|
|
||||||
The GF Resource Grammar Library is the standard library for Grammatical Framework.
|
The GF Resource Grammar Library is the standard library for Grammatical Framework.
|
||||||
It covers the morphology and basic syntax of currently 34 languages:
|
It covers the morphology and basic syntax of currently #LANGUAGE_COUNT languages:
|
||||||
Afrikaans,
|
#LANGUAGES
|
||||||
Arabic,
|
|
||||||
Bulgarian,
|
|
||||||
Catalan,
|
|
||||||
Chinese (simplified),
|
|
||||||
Danish,
|
|
||||||
Dutch,
|
|
||||||
English,
|
|
||||||
Estonian,
|
|
||||||
Finnish,
|
|
||||||
French,
|
|
||||||
German,
|
|
||||||
Greek,
|
|
||||||
Hindi,
|
|
||||||
Icelandic,
|
|
||||||
Japanese,
|
|
||||||
Italian,
|
|
||||||
Latvian,
|
|
||||||
Maltese,
|
|
||||||
Mongolian,
|
|
||||||
Nepali,
|
|
||||||
Norwegian (bokmål),
|
|
||||||
Norwegial (nynorsk),
|
|
||||||
Persian,
|
|
||||||
Polish,
|
|
||||||
Portuguese,
|
|
||||||
Punjabi,
|
|
||||||
Romanian,
|
|
||||||
Russian,
|
|
||||||
Sindhi,
|
|
||||||
Spanish,
|
|
||||||
Swedish,
|
|
||||||
Thai,
|
|
||||||
Urdu.
|
|
||||||
|
|
||||||
This document contains the most important parts of the GF Resource Grammar API,
|
This document contains the most important parts of the GF Resource Grammar API,
|
||||||
as needed by a GF application programmer.
|
as needed by a GF application programmer.
|
||||||
|
|||||||
Reference in New Issue
Block a user