start translation into German and French with one step as well as the report

This commit is contained in:
Bernd Hahnebach
2020-12-15 00:04:26 +01:00
committed by Dion Moult
parent 17a8b33387
commit d00da09cdc
7 changed files with 94 additions and 14 deletions
+39 -6
View File
@@ -7,10 +7,10 @@ import pystache
def generate_report(adir="."):
print("# Generating HTML reports now.")
# get html template
html_template_file = os.path.join(
# get html template path
report_template_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"features/template.html"
"features/"
)
# get report file
@@ -93,7 +93,40 @@ def generate_report(adir="."):
data["total_steps"] = sum([s["total_steps"] for s in data["scenarios"]])
data["pass_rate"] = round((data["total_passes"] / data["total_steps"]) * 100)
html_report_file = os.path.join(report_dir, "{}.html".format(file_name))
with open(html_report_file, "w") as out:
with open(html_template_file) as template:
# translate report
# json.dump(mydict, myfile, indent=4)
# workaround for retrieving the feature file language
print(feature["keyword"])
if feature["keyword"] == "Feature":
strings_file_report = os.path.join(
report_template_path,
"strings_template_en.json"
)
elif feature["keyword"] == "Funktionalität":
strings_file_report = os.path.join(
report_template_path,
"strings_template_de.json"
)
elif feature["keyword"] == "Fonctionnalité":
strings_file_report = os.path.join(
report_template_path,
"strings_template_fr.json"
)
else:
# standard English
strings_file_report = os.path.join(
report_template_path,
"strings_template_en.json"
)
strings_report = json.loads(
open(strings_file_report, encoding="utf8").read()
)
# print(strings_report)
data.update(strings_report)
# print(data)
html_report = os.path.join(report_dir, "{}.html".format(file_name))
html_tmpl = os.path.join(report_template_path, "template.html")
with open(html_report, "w", encoding="utf8") as out:
with open(html_tmpl, encoding="utf8") as template:
out.write(pystache.render(template.read(), data))