mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
start translation into German and French with one step as well as the report
This commit is contained in:
committed by
Dion Moult
parent
17a8b33387
commit
d00da09cdc
@@ -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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang={{tr_lang}}>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="foobaro">
|
<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">
|
<link href="https://fonts.googleapis.com/css?family=Comfortaa|Inconsolata|Open+Sans&display=swap" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body { font-family: 'Arial', sans-serif; padding: 40px; }
|
body { font-family: 'Arial', sans-serif; padding: 40px; }
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
<h1>{{name}}</h1>
|
<h1>{{name}}</h1>
|
||||||
<p><strong>{{time}} {{file_name}}</strong></p>
|
<p><strong>{{time}} {{file_name}}</strong></p>
|
||||||
<hr>
|
<hr>
|
||||||
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
|
<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>
|
||||||
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
|
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
|
||||||
<br />
|
<br />
|
||||||
<p class="description">
|
<p class="description">
|
||||||
{{#description}}
|
{{#description}}
|
||||||
@@ -44,10 +44,10 @@
|
|||||||
<section>
|
<section>
|
||||||
<h2>{{name}}</h2>
|
<h2>{{name}}</h2>
|
||||||
<p>
|
<p>
|
||||||
<span class="{{#is_success}}success{{/is_success}}{{^is_success}}failure{{/is_success}}">{{#is_success}}Success{{/is_success}}{{^is_success}}Failure{{/is_success}}</span>
|
<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>
|
||||||
Tests passed: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
|
{{tr_tests_passed}}: <strong>{{total_passes}} / {{total_steps}}</strong> ({{pass_rate}}%)
|
||||||
<span class="time">
|
<span class="time">
|
||||||
Duration: {{time}}s
|
{{tr_duration}}: {{time}}s
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<ol>
|
<ol>
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<footer>
|
<footer>
|
||||||
<p>
|
<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>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import pystache
|
|||||||
def generate_report(adir="."):
|
def generate_report(adir="."):
|
||||||
print("# Generating HTML reports now.")
|
print("# Generating HTML reports now.")
|
||||||
|
|
||||||
# get html template
|
# get html template path
|
||||||
html_template_file = os.path.join(
|
report_template_path = os.path.join(
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
"features/template.html"
|
"features/"
|
||||||
)
|
)
|
||||||
|
|
||||||
# get report file
|
# get report file
|
||||||
@@ -93,7 +93,40 @@ def generate_report(adir="."):
|
|||||||
data["total_steps"] = sum([s["total_steps"] for s in data["scenarios"]])
|
data["total_steps"] = sum([s["total_steps"] for s in data["scenarios"]])
|
||||||
data["pass_rate"] = round((data["total_passes"] / data["total_steps"]) * 100)
|
data["pass_rate"] = round((data["total_passes"] / data["total_steps"]) * 100)
|
||||||
|
|
||||||
html_report_file = os.path.join(report_dir, "{}.html".format(file_name))
|
# translate report
|
||||||
with open(html_report_file, "w") as out:
|
# json.dump(mydict, myfile, indent=4)
|
||||||
with open(html_template_file) as template:
|
# 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))
|
out.write(pystache.render(template.read(), data))
|
||||||
|
|||||||
Reference in New Issue
Block a user