Skip to content

Commit 89d2d9c

Browse files
committed
Documentation: Add German Versions.
Add support for building and serving the German versions of the manual and mobile manual. Signed-off-by: Michael Keller <[email protected]>
1 parent ed3ea23 commit 89d2d9c

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ subsurface/
66
src/web/templates/SupportedDivecomputers.html
77
src/web/persistent.store
88
src/web/static/user-manual.html
9+
src/web/static/user-manual_de.html
910
src/web/static/images
1011
src/web/static/mobile-user-manual.html
12+
src/web/static/mobile-user-manual_de.html
1113
src/web/static/mobile-images/

src/web/server.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,28 @@ def mobile_user_manual_images(path):
179179
return send_from_directory(os.path.join(app.root_path, "static/mobile-images"), path)
180180

181181

182+
def _serve_user_manual(base_filename):
183+
language = request.args.get("lang")
184+
static_dir = os.path.join(app.root_path, "static")
185+
186+
if language and language[:2].isalpha():
187+
file_name = f"{base_filename}_{language[:2]}.html"
188+
file_path = os.path.join(static_dir, file_name)
189+
if os.path.exists(file_path):
190+
return send_from_directory(static_dir, file_name)
191+
192+
return send_from_directory(static_dir, f"{base_filename}.html")
193+
194+
182195
@app.route("/subsurface-user-manual/")
183196
def static_user_manual():
184-
return send_from_directory(os.path.join(app.root_path, "static"), "user-manual.html")
197+
return _serve_user_manual("user-manual")
185198

186199

187200
@app.route("/subsurface-mobile-v3-user-manual/")
188201
@app.route("/subsurface-mobile-user-manual/")
189202
def static_mobile_user_manual():
190-
return send_from_directory(os.path.join(app.root_path, "static"), "mobile-user-manual.html")
203+
return _serve_user_manual("mobile-user-manual")
191204

192205

193206
@app.route("/release-changes/")

src/web/subsurfacesync.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,26 @@ def sync(self):
8585
)
8686
try:
8787
subprocess.run(
88-
f"cd {self._myroot}/subsurface/Documentation; make output/user-manual.html output/mobile-manual-v3.html", shell=True, check=True
88+
f"cd {self._myroot}/subsurface/Documentation; make output/user-manual.html output/user-manual_de.html output/mobile-manual-v3.html output/mobile-manual_de.html", shell=True, check=True
8989
)
9090
except subprocess.CalledProcessError:
9191
print("issue building the latest Subsurface documentation - please check")
9292
shutil.copy(
9393
f"{self._myroot}/subsurface/Documentation/output/user-manual.html",
9494
f"{self._myroot}/src/web/static/user-manual.html",
9595
)
96+
shutil.copy(
97+
f"{self._myroot}/subsurface/Documentation/output/user-manual_de.html",
98+
f"{self._myroot}/src/web/static/user-manual_de.html",
99+
)
96100
shutil.copy(
97101
f"{self._myroot}/subsurface/Documentation/output/mobile-manual-v3.html",
98102
f"{self._myroot}/src/web/static/mobile-user-manual.html",
99103
)
104+
shutil.copy(
105+
f"{self._myroot}/subsurface/Documentation/output/mobile-manual_de.html",
106+
f"{self._myroot}/src/web/static/mobile-user-manual_de.html",
107+
)
100108
shutil.copytree(
101109
f"{self._myroot}/subsurface/Documentation/output/images",
102110
f"{self._myroot}/src/web/static/images",

0 commit comments

Comments
 (0)