diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2009-02-20 15:22:56 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2009-02-20 15:22:56 (GMT) |
commit | ff19280d3496f5ab5f2d3f45e688faf2371fa914 (patch) | |
tree | ba0fb0d27eb482c925eadc48c5fe9ffc9a4f87c0 /svg/kbinput.py | |
parent | b61af89c39a7ec7086b572b3b376f5638e98791a (diff) |
adding python code to generate svg files from .po
Diffstat (limited to 'svg/kbinput.py')
-rw-r--r-- | svg/kbinput.py | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/svg/kbinput.py b/svg/kbinput.py new file mode 100644 index 0000000..c0de47b --- /dev/null +++ b/svg/kbinput.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +#Copyright (c) 2009, Sugar Labs + +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is +#furnished to do so, subject to the following conditions: + +#The above copyright notice and this permission notice shall be included in +#all copies or substantial portions of the Software. + +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +#THE SOFTWARE. + +import sys +import os +import os.path +import gettext + +def main(): + + myname = "kbinput" + mystring1 = "read key" + mygroup = "sensors" + + if len(sys.argv) != 2: + print "Error: Usage is " + myname + ".py lang" + return + + t = gettext.translation("org.laptop.TurtleArtActivity", "../locale", languages=[sys.argv[1]]) + _ = t.ugettext + t.install() + + print _(mystring1) + + data0 = \ +"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> \n \ +<!-- Created with Inkscape (http://www.inkscape.org/) --> \n \ +<svg \n \ + xmlns:svg=\"http://www.w3.org/2000/svg\" \n \ + xmlns=\"http://www.w3.org/2000/svg\" \n \ + xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n \ + version=\"1.0\" \n \ + width=\"87\" \n \ + height=\"60\" \n \ + id=\"svg2\"> \n \ + <defs \n \ + id=\"defs4\"> \n \ + <linearGradient \n \ + id=\"linearGradient3166\"> \n \ + <stop \n \ + id=\"stop3168\" \n \ + style=\"stop-color:#ffffff;stop-opacity:1\" \n \ + offset=\"0\" /> \n \ + <stop \n \ + id=\"stop3170\" \n \ + style=\"stop-color:#ff0000;stop-opacity:1\" \n \ + offset=\"1\" /> \n \ + </linearGradient> \n \ + <linearGradient \n \ + x1=\"0\" \n \ + y1=\"22\" \n \ + x2=\"74\" \n \ + y2=\"22\" \n \ + id=\"linearGradient3172\" \n \ + xlink:href=\"#linearGradient3166\" \n \ + gradientUnits=\"userSpaceOnUse\" /> \n \ + </defs> \n \ + <path \n \ + d=\"M 48,1 C 64,1 64,1 64,1 L 69.5,5 L 73,11 L 73,45 L 69.5,51 L 64,55 L 47,55 L 47,55 L 47,59 L 27,59 L 27,55 L 10,55 L 4.5,51 L 1,45 L 1,11 L 4.5,5 L 10,1 L 26,1 L 26,6 L 48,6 L 48,1 z\" \n \ + id=\"path10\" \n \ + style=\"fill:url(#linearGradient3172);fill-opacity:1;stroke:#c00000;stroke-width:2;stroke-opacity:1\" /> \n " + + data1a = \ +" <text \n \ + id=\"text12\" \n \ + style=\"font-size:18px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans\"> \n \ + <tspan \n \ + x=\"37\" \n \ + y=\"36\" \n \ + id=\"tspan14\" \n \ + style=\"font-size:18px\">" + + data1b = \ +" <text \n \ + id=\"text12\" \n \ + style=\"font-size:18px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans\"> \n \ + <tspan \n \ + x=\"37\" \n \ + y=\"27\" \n \ + id=\"tspan14\" \n \ + style=\"font-size:18px\">" + + data2b = \ +"</tspan> \n \ + </text> \n \ + <text \n \ + id=\"text16\" \n \ + style=\"font-size:18px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans\"> \n \ + <tspan \n \ + x=\"37\" \n \ + y=\"46\" \n \ + id=\"tspan18\" \n \ + style=\"font-size:18px\">" + + data3 = \ +"</tspan> \n \ + </text> \n \ +</svg> \n" + + + FILE = open(os.path.join("../images", sys.argv[1], mygroup, myname + ".svg"), "w") + FILE.write(data0) + strings = _(mystring1).split(" ",2) + if len(strings) == 1: + FILE.write(data1a) + FILE.write(strings[0].encode("utf-8")) + else: + FILE.write(data1b) + FILE.write(strings[0].encode("utf-8")) + FILE.write(data2b) + FILE.write(strings[1].encode("utf-8")) + FILE.write(data3) + FILE.close() + return + +if __name__ == "__main__": + main() + |