mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
Added languageCode function to the PGF API.
This commit is contained in:
13
src/PGF.hs
13
src/PGF.hs
@@ -22,7 +22,7 @@ module PGF(
|
|||||||
CId, mkCId, prCId,
|
CId, mkCId, prCId,
|
||||||
|
|
||||||
-- ** Language
|
-- ** Language
|
||||||
Language, languages, abstractName,
|
Language, languages, abstractName, languageCode,
|
||||||
|
|
||||||
-- ** Category
|
-- ** Category
|
||||||
Category, categories, startCat,
|
Category, categories, startCat,
|
||||||
@@ -68,6 +68,7 @@ import qualified PGF.Parsing.FCFG.Incremental as Incremental
|
|||||||
import GF.Text.UTF8
|
import GF.Text.UTF8
|
||||||
|
|
||||||
import GF.Data.ErrM
|
import GF.Data.ErrM
|
||||||
|
import GF.Data.Utilities
|
||||||
|
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import System.Random (newStdGen)
|
import System.Random (newStdGen)
|
||||||
@@ -153,6 +154,13 @@ generateAllDepth :: PGF -> Category -> Maybe Int -> [Tree]
|
|||||||
-- | List of all languages available in the given grammar.
|
-- | List of all languages available in the given grammar.
|
||||||
languages :: PGF -> [Language]
|
languages :: PGF -> [Language]
|
||||||
|
|
||||||
|
-- | Gets the RFC 4646 language tag
|
||||||
|
-- of the language which the given concrete syntax implements,
|
||||||
|
-- if this is listed in the source grammar.
|
||||||
|
-- Example language tags include @"en"@ for English,
|
||||||
|
-- and @"en-UK"@ for British English.
|
||||||
|
languageCode :: PGF -> Language -> Maybe String
|
||||||
|
|
||||||
-- | The abstract language name is the name of the top-level
|
-- | The abstract language name is the name of the top-level
|
||||||
-- abstract module
|
-- abstract module
|
||||||
abstractName :: PGF -> Language
|
abstractName :: PGF -> Language
|
||||||
@@ -219,6 +227,9 @@ abstractName pgf = prCId (absname pgf)
|
|||||||
|
|
||||||
languages pgf = [prCId l | l <- cncnames pgf]
|
languages pgf = [prCId l | l <- cncnames pgf]
|
||||||
|
|
||||||
|
languageCode pgf lang =
|
||||||
|
fmap (replace '_' '-') $ lookConcrFlag pgf (mkCId lang) (mkCId "language")
|
||||||
|
|
||||||
categories pgf = [prCId c | c <- Map.keys (cats (abstract pgf))]
|
categories pgf = [prCId c | c <- Map.keys (cats (abstract pgf))]
|
||||||
|
|
||||||
startCat pgf = lookStartCat pgf
|
startCat pgf = lookStartCat pgf
|
||||||
|
|||||||
Reference in New Issue
Block a user