diff options
| author | bringert <bringert@cs.chalmers.se> | 2007-01-21 16:33:44 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2007-01-21 16:33:44 +0000 |
| commit | 169659c096a38f8fc0cf48e3054efbdf30a96c8c (patch) | |
| tree | baf3f08f571514fe113055ce7dfd321e746b1f44 /src/GF/Speech/GrammarToVoiceXML.hs | |
| parent | b974ab06cdd64ba1db9278516fbd5803f236d5ee (diff) | |
Get speechLanguage flag from both command-line and grammar. Reformat it to RFC3066 format (- instead of _) and use it in SRGS, VoiceXML and JSGF.
Diffstat (limited to 'src/GF/Speech/GrammarToVoiceXML.hs')
| -rw-r--r-- | src/GF/Speech/GrammarToVoiceXML.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/GF/Speech/GrammarToVoiceXML.hs b/src/GF/Speech/GrammarToVoiceXML.hs index 961f021f5..b48af5a57 100644 --- a/src/GF/Speech/GrammarToVoiceXML.hs +++ b/src/GF/Speech/GrammarToVoiceXML.hs @@ -21,12 +21,13 @@ import GF.Canon.CMacros (noMark, strsFromTerm) import GF.Canon.Unlex (formatAsText) import GF.Data.Utilities import GF.CF.CFIdent (cfCat2Ident) -import GF.Compile.ShellState (StateGrammar,stateGrammarST,cncId,grammar,startCatStateOpts) +import GF.Compile.ShellState (StateGrammar,stateGrammarST,cncId,grammar, + startCatStateOpts,stateOptions) import GF.Data.Str (sstrV) import GF.Grammar.Macros hiding (assign,strsFromTerm) import GF.Grammar.Grammar (Fun) import GF.Grammar.Values (Tree) -import GF.Infra.Option (Options) +import GF.Infra.Option (Options, addOptions, getOptVal, speechLanguage) import GF.UseGrammar.GetTree (string2treeErr) import GF.UseGrammar.Linear (linTree2strings) @@ -45,10 +46,11 @@ import Debug.Trace -- | the main function grammar2vxml :: Options -> StateGrammar -> String -grammar2vxml opts s = showsXMLDoc (skel2vxml name language startcat gr' qs) "" +grammar2vxml opt s = showsXMLDoc (skel2vxml name language startcat gr' qs) "" where (name, gr') = vSkeleton (stateGrammarST s) qs = catQuestions s (map fst gr') - language = "en" -- FIXME: use speechLanguage tag + opts = addOptions opt (stateOptions s) + language = fmap (replace '_' '-') $ getOptVal opts speechLanguage startcat = C.CId $ prIdent $ cfCat2Ident $ startCatStateOpts opts s -- @@ -117,7 +119,7 @@ getCatQuestion c qs = -- * Generate VoiceXML -- -skel2vxml :: VIdent -> String -> VIdent -> VSkeleton -> CatQuestions -> XML +skel2vxml :: VIdent -> Maybe String -> VIdent -> VSkeleton -> CatQuestions -> XML skel2vxml name language start skel qs = vxml language ([startForm] ++ concatMap (uncurry (catForms gr qs)) skel) where @@ -169,10 +171,10 @@ catFormId c = prid c ++ "_cat" -- * VoiceXML stuff -- -vxml :: String -> [XML] -> XML -vxml language = Tag "vxml" [("version","2.0"), - ("xmlns","http://www.w3.org/2001/vxml"), - ("xml:lang", language)] +vxml :: Maybe String -> [XML] -> XML +vxml ml = Tag "vxml" $ [("version","2.0"), + ("xmlns","http://www.w3.org/2001/vxml")] + ++ maybe [] (\l -> [("xml:lang", l)]) ml form :: String -> [XML] -> XML form id xs = Tag "form" [("id", id)] xs |
