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
|
||||
|
||||
# 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
|
||||
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 System.Process(system)
|
||||
import System.Environment(getArgs)
|
||||
import System.FilePath((</>),(<.>))
|
||||
import Data.Char
|
||||
import Data.List
|
||||
@@ -24,19 +23,10 @@ configFile = ".." </> ".." </> Config.configFile
|
||||
revealedLang :: String
|
||||
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
|
||||
main :: IO ()
|
||||
main = do
|
||||
langs <- loadLangsFrom configFile >>= return . filter langSynopsis
|
||||
cs1 <- getCats commonAPI
|
||||
cs2 <- getCats catAPI
|
||||
let cs = sortCats (cs1 ++ cs2)
|
||||
@@ -50,8 +40,10 @@ main = do
|
||||
append "%!postproc(html): '#EUL' '</ul>'"
|
||||
append "%!postproc(html): '#LI' '<li>'"
|
||||
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
|
||||
include "intro.txt" -- TODO dynamic language list
|
||||
include "intro.txt"
|
||||
space
|
||||
title "Categories"
|
||||
space
|
||||
@@ -72,7 +64,7 @@ main = do
|
||||
space
|
||||
link "Source 2:" structuralAPI
|
||||
space
|
||||
apiExx <- apiExxFiles >>= getApiExx
|
||||
apiExx <- getApiExx (apiExxFiles langs)
|
||||
rs <- getRules apiExx syntaxAPI
|
||||
rs2 <- getRules apiExx structuralAPI
|
||||
let rss = rs ++ rs2
|
||||
@@ -87,7 +79,7 @@ main = do
|
||||
space
|
||||
title "Lexical Paradigms"
|
||||
append "#LParadigms"
|
||||
paradigmFiles >>= mapM_ (putParadigms cs)
|
||||
mapM_ (putParadigms cs) (paradigmFiles langs)
|
||||
space
|
||||
include "additional.txt"
|
||||
space
|
||||
@@ -242,20 +234,18 @@ catAPI = srcPath "abstract/Cat.gf"
|
||||
syntaxAPI = srcPath "api/Constructors.gf"
|
||||
structuralAPI = srcPath "abstract/Structural.gf"
|
||||
|
||||
paradigmFiles :: IO [(String,FilePath)]
|
||||
paradigmFiles = do
|
||||
langs <- loadLangsFrom configFile
|
||||
return $
|
||||
[ (name, srcPath $ printf "%s/Paradigms%s.gf" (langDir lang) (langCode lang))
|
||||
| lang <- langs
|
||||
, langSynopsis lang
|
||||
, let name = formatName (langDir lang)
|
||||
]
|
||||
-- all languages shown (a copy of this list appears in Makefile)
|
||||
apiExxFiles :: [LangInfo] -> [FilePath]
|
||||
apiExxFiles langs =
|
||||
[ "api-examples-" ++ (langCode lang) ++ ".txt"
|
||||
| lang <- langs
|
||||
]
|
||||
|
||||
-- | Format language name from directory name
|
||||
-- "ancient_greek -> Ancient Greek"
|
||||
formatName :: String -> String
|
||||
formatName = unwords . map (\(s:ss) -> toUpper s : ss) . splitOn (=='_')
|
||||
paradigmFiles :: [LangInfo] -> [(String,FilePath)]
|
||||
paradigmFiles langs =
|
||||
[ (langName lang, srcPath $ printf "%s/Paradigms%s.gf" (langDir lang) (langCode lang))
|
||||
| lang <- langs
|
||||
]
|
||||
|
||||
-- | Split a string at given character, similar to words
|
||||
splitOn :: (Char -> Bool) -> String -> [String]
|
||||
|
||||
@@ -3,41 +3,8 @@
|
||||
=Introduction=
|
||||
|
||||
The GF Resource Grammar Library is the standard library for Grammatical Framework.
|
||||
It covers the morphology and basic syntax of currently 34 languages:
|
||||
Afrikaans,
|
||||
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.
|
||||
It covers the morphology and basic syntax of currently #LANGUAGE_COUNT languages:
|
||||
#LANGUAGES
|
||||
|
||||
This document contains the most important parts of the GF Resource Grammar API,
|
||||
as needed by a GF application programmer.
|
||||
|
||||
Reference in New Issue
Block a user