forked from GitHub/gf-core
started a script and format for updating a set of gf files
This commit is contained in:
23
examples/phrasebook/Update.hs
Normal file
23
examples/phrasebook/Update.hs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import System
|
||||||
|
|
||||||
|
main = do
|
||||||
|
file:_ <- getArgs
|
||||||
|
updates <- readFile file >= return . readUpdates
|
||||||
|
mapM_ (doUpdate file) updates
|
||||||
|
return ()
|
||||||
|
|
||||||
|
type Update = (FilePath, [String])
|
||||||
|
|
||||||
|
readUpdates :: String -> [Update]
|
||||||
|
readUpdates s = []
|
||||||
|
|
||||||
|
doUpdate :: FilePath -> Update -> IO ()
|
||||||
|
doUpdate src (target,ls) = do
|
||||||
|
s <- readFile target
|
||||||
|
let beg = dropLastBracket s
|
||||||
|
let tmp = tmpFile target
|
||||||
|
writeFile tmp beg
|
||||||
|
appendFile tmp $ unlines [(line ++ "-- UPDATE FROM " ++ src) | line <- ls]
|
||||||
|
appendFile tmp "\n}\n"
|
||||||
|
|
||||||
|
dropLastBracket s = s
|
||||||
12
examples/phrasebook/add_greetings.gfupdate
Normal file
12
examples/phrasebook/add_greetings.gfupdate
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
abstract Greetings
|
||||||
|
|
||||||
|
fun GCongratulations : Greeting ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Eng = ss "congratulations" ;
|
||||||
|
Fin = ss "onneksi olkoon" ;
|
||||||
|
Fre = ss "félicitations" ;
|
||||||
|
Ita = ss "auguri" ;
|
||||||
|
Swe = ss "grattis" ;
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user