Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit d00da09

Browse files
berndhahnebachMoult
authored andcommitted
start translation into German and French with one step as well as the report
1 parent 17a8b33 commit d00da09

7 files changed

Lines changed: 94 additions & 14 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from behave import step
2+
3+
# https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps
4+
5+
6+
@step("Die IFC daten müssen das {schema} Schema benutzen")
7+
def step_impl(context, schema):
8+
context.execute_steps(
9+
"* IFC data must use the {schema} schema".format(schema=schema)
10+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from behave import step
2+
3+
# https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps
4+
5+
6+
@step("Les données IFC doivent utiliser le schéma {schema}")
7+
def step_impl(context, schema):
8+
context.execute_steps(
9+
"* IFC data must use the {aschema} schema".format(aschema=schema)
10+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tr_lang": "de",
3+
"tr_success": "Bestanden",
4+
"tr_failure": "Durchgefallen",
5+
"tr_tests_passed": "Erfolgreiche Tests",
6+
"tr_duration": "Dauer",
7+
"tr_auditing": "OpenBIM auditing ist eine Funktionalität von",
8+
"tr_and": "und"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tr_lang": "en",
3+
"tr_success": "Success",
4+
"tr_failure": "Failure",
5+
"tr_tests_passed": "Tests passed",
6+
"tr_duration": "Duration",
7+
"tr_auditing": "OpenBIM auditing is a feature of",
8+
"tr_and": "and"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tr_lang": "fr",
3+
"tr_success": "Succès",
4+
"tr_failure": "Échec",
5+
"tr_tests_passed": "Tests réussis",
6+
"tr_duration": "Durée",
7+
"tr_auditing": "L'audit OpenBIM auditing est une fonctionnalité de",
8+
"tr_and": "et"
9+
}

src/ifcbimtester/bimtester/features/template.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang={{tr_lang}}>
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta name="description" content="foobaro">
7-
<title>BlenderBIM</title>
7+
<title>{{name}}</title>
88
<link href="https://fonts.googleapis.com/css?family=Comfortaa|Inconsolata|Open+Sans&display=swap" rel="stylesheet">
99
<style>
1010
body { font-family: 'Arial', sans-serif; padding: 40px; }
@@ -30,8 +30,8 @@
3030
<h1>{{name}}</h1>
3131
<p><strong>{{time}} {{file_name}}</strong></p>
3232
<hr>
33-
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
34-
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
33+
<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>
34+
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
3535
<br />
3636
<p class="description">
3737
{{#description}}
@@ -44,10 +44,10 @@ <h1>{{name}}</h1>
4444
<section>
4545
<h2>{{name}}</h2>
4646
<p>
47-
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
48-
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
47+
<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>
48+
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
4949
<span class="time">
50-
Duration: {{time}}s
50+
{{tr_duration}}: {{time}}s
5151
</span>
5252
</p>
5353
<ol>
@@ -70,7 +70,7 @@ <h2>{{name}}</h2>
7070
<hr>
7171
<footer>
7272
<p>
73-
OpenBIM auditing is a feature of <a href="https://blenderbim.org/">BlenderBIM</a> and <a href="http://ifcopenshell.org/">IfcOpenShell</a>.
73+
{{tr_auditing}} <a href="https://blenderbim.org/">BlenderBIM</a> {{tr_and}} <a href="http://ifcopenshell.org/">IfcOpenShell</a>.
7474
</p>
7575
</footer>
7676
</body>

src/ifcbimtester/bimtester/reports.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
def generate_report(adir="."):
88
print("# Generating HTML reports now.")
99

10-
# get html template
11-
html_template_file = os.path.join(
10+
# get html template path
11+
report_template_path = os.path.join(
1212
os.path.dirname(os.path.realpath(__file__)),
13-
"features/template.html"
13+
"features/"
1414
)
1515

1616
# get report file
@@ -93,7 +93,40 @@ def generate_report(adir="."):
9393
data["total_steps"] = sum([s["total_steps"] for s in data["scenarios"]])
9494
data["pass_rate"] = round((data["total_passes"] / data["total_steps"]) * 100)
9595

96-
html_report_file = os.path.join(report_dir, "{}.html".format(file_name))
97-
with open(html_report_file, "w") as out:
98-
with open(html_template_file) as template:
96+
# translate report
97+
# json.dump(mydict, myfile, indent=4)
98+
# workaround for retrieving the feature file language
99+
print(feature["keyword"])
100+
if feature["keyword"] == "Feature":
101+
strings_file_report = os.path.join(
102+
report_template_path,
103+
"strings_template_en.json"
104+
)
105+
elif feature["keyword"] == "Funktionalität":
106+
strings_file_report = os.path.join(
107+
report_template_path,
108+
"strings_template_de.json"
109+
)
110+
elif feature["keyword"] == "Fonctionnalité":
111+
strings_file_report = os.path.join(
112+
report_template_path,
113+
"strings_template_fr.json"
114+
)
115+
else:
116+
# standard English
117+
strings_file_report = os.path.join(
118+
report_template_path,
119+
"strings_template_en.json"
120+
)
121+
strings_report = json.loads(
122+
open(strings_file_report, encoding="utf8").read()
123+
)
124+
# print(strings_report)
125+
data.update(strings_report)
126+
# print(data)
127+
128+
html_report = os.path.join(report_dir, "{}.html".format(file_name))
129+
html_tmpl = os.path.join(report_template_path, "template.html")
130+
with open(html_report, "w", encoding="utf8") as out:
131+
with open(html_tmpl, encoding="utf8") as template:
99132
out.write(pystache.render(template.read(), data))

0 commit comments

Comments
 (0)