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
@@ -0,0 +1,10 @@
from behave import step
# https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps
@step("Die IFC daten müssen das {schema} Schema benutzen")
def step_impl(context, schema):
context.execute_steps(
"* IFC data must use the {schema} schema".format(schema=schema)
)
@@ -0,0 +1,10 @@
from behave import step
# https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps
@step("Les données IFC doivent utiliser le schéma {schema}")
def step_impl(context, schema):
context.execute_steps(
"* IFC data must use the {aschema} schema".format(aschema=schema)
)
@@ -0,0 +1,9 @@
{
"tr_lang": "de",
"tr_success": "Bestanden",
"tr_failure": "Durchgefallen",
"tr_tests_passed": "Erfolgreiche Tests",
"tr_duration": "Dauer",
"tr_auditing": "OpenBIM auditing ist eine Funktionalität von",
"tr_and": "und"
}
@@ -0,0 +1,9 @@
{
"tr_lang": "en",
"tr_success": "Success",
"tr_failure": "Failure",
"tr_tests_passed": "Tests passed",
"tr_duration": "Duration",
"tr_auditing": "OpenBIM auditing is a feature of",
"tr_and": "and"
}
@@ -0,0 +1,9 @@
{
"tr_lang": "fr",
"tr_success": "Succès",
"tr_failure": "Échec",
"tr_tests_passed": "Tests réussis",
"tr_duration": "Durée",
"tr_auditing": "L'audit OpenBIM auditing est une fonctionnalité de",
"tr_and": "et"
}
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<html lang={{tr_lang}}>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="foobaro">
<title>BlenderBIM</title>
<title>{{name}}</title>
<link href="https://fonts.googleapis.com/css?family=Comfortaa|Inconsolata|Open+Sans&display=swap" rel="stylesheet">
<style>
body { font-family: 'Arial', sans-serif; padding: 40px; }
@@ -30,8 +30,8 @@
<h1>{{name}}</h1>
<p><strong>{{time}} {{file_name}}</strong></p>
<hr>
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}{{tr_success}}{{/is_success}}{{^is_success}}{{tr_failure}}{{/is_success}}</span>
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
<br />
<p class="description">
{{#description}}
@@ -44,10 +44,10 @@
<section>
<h2>{{name}}</h2>
<p>
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}{{tr_success}}{{/is_success}}{{^is_success}}{{tr_failure}}{{/is_success}}</span>
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
<span class="time">
Duration: {{time}}s
{{tr_duration}}: {{time}}s
</span>
</p>
<ol>
@@ -70,7 +70,7 @@
<hr>
<footer>
<p>
OpenBIM auditing is a feature of <a href="https://blenderbim.org/">BlenderBIM</a> and <a href="http://ifcopenshell.org/">IfcOpenShell</a>.
{{tr_auditing}} <a href="https://blenderbim.org/">BlenderBIM</a> {{tr_and}} <a href="http://ifcopenshell.org/">IfcOpenShell</a>.
</p>
</footer>
</body>
+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))