2014-11-07 16:28:27 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
""" This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext."""
|
|
|
|
|
|
|
|
def prepare_documentation_in_file(fileSource, fileDest):
|
|
|
|
""" This takes documentation written in a markdown file and put all the contents in a python file, to create a internationalized documentation.
|
|
|
|
@fileSource str: A markdown(.md) file.
|
|
|
|
@fileDest str: A file where this will put the new strings"""
|
|
|
|
|
|
|
|
f1 = open(fileSource, "r")
|
|
|
|
f2 = open(fileDest, "w")
|
|
|
|
lns = f1.readlines()
|
|
|
|
f2.write("# -*- coding: utf-8 -*-\n")
|
2016-08-04 09:19:47 -05:00
|
|
|
f2.write("documentation = [\n")
|
2014-11-07 16:28:27 -06:00
|
|
|
for i in lns:
|
2016-08-04 09:19:47 -05:00
|
|
|
if "\n" == i:
|
|
|
|
newvar = "\"\","
|
|
|
|
elif "\n" == i[-1]:
|
|
|
|
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i[:-1])
|
2014-11-07 16:28:27 -06:00
|
|
|
else:
|
2016-08-04 09:19:47 -05:00
|
|
|
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i)
|
|
|
|
# print i[-1:]
|
2014-11-07 16:28:27 -06:00
|
|
|
f2.write(newvar)
|
|
|
|
f1.close()
|
2016-08-04 09:19:47 -05:00
|
|
|
f2.write("]")
|
2014-11-07 16:28:27 -06:00
|
|
|
f2.close()
|
|
|
|
|
|
|
|
|
2016-08-04 09:19:47 -05:00
|
|
|
prepare_documentation_in_file("manual.md", "strings.py")
|