summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/GF/Command')
-rw-r--r--src/compiler/GF/Command/Commands.hs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index cef46516b..e7beec23e 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -628,14 +628,18 @@ allCommands env@(pgf, mos) = Map.fromList [
"gr -cat=QCl | l | ps -bind -- linearization output from LangFin",
"ps -to_devanagari \"A-p\" -- show Devanagari in UTF8 terminal",
"rf -file=Hin.gf | ps -env=quotes -to_devanagari -- convert translit to UTF8",
- "rf -file=Ara.gf | ps -from_utf8 -env=quotes -from_arabic -- convert UTF8 to transliteration"
+ "rf -file=Ara.gf | ps -from_utf8 -env=quotes -from_arabic -- convert UTF8 to transliteration",
+ "ps -to=chinese.trans \"abc\" -- apply transliteration defined in file chinese.trans"
],
- exec = \opts ->
- let (os,fs) = optsAndFlags opts in
- return . fromString . stringOps (envFlag fs) (map prOpt os) . toString,
+ exec = \opts x -> do
+ let (os,fs) = optsAndFlags opts
+ trans <- optTranslit opts
+ return ((fromString . trans . stringOps (envFlag fs) (map prOpt os) . toString) x),
options = stringOpOptions,
flags = [
- ("env","apply in this environment only")
+ ("env","apply in this environment only"),
+ ("from","backward-apply transliteration defined in this file (format 'unicode translit' per line)"),
+ ("to", "forward-apply transliteration defined in this file")
]
}),
("pt", emptyCommandInfo {
@@ -1100,6 +1104,15 @@ allCommands env@(pgf, mos) = Map.fromList [
probs <- readProbabilitiesFromFile file pgf
return (setProbabilities probs pgf)
+ optTranslit opts = case (valStrOpts "to" "" opts, valStrOpts "from" "" opts) of
+ ("","") -> return id
+ (file,"") -> do
+ src <- readFile file
+ return $ transliterateWithFile file src False
+ (_,file) -> do
+ src <- readFile file
+ return $ transliterateWithFile file src True
+
optFile opts = valStrOpts "file" "_gftmp" opts
optType opts =