aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla')
-rw-r--r--src/hydrilla/proxy/self_doc.py8
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/advanced_ui_features.html.jinja (renamed from src/hydrilla/proxy/self_doc/advanced_ui_features.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/doc_index.html.jinja (renamed from src/hydrilla/proxy/self_doc/doc_index.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/packages.html.jinja (renamed from src/hydrilla/proxy/self_doc/packages.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/policy_selection.html.jinja (renamed from src/hydrilla/proxy/self_doc/policy_selection.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/popup.html.jinja (renamed from src/hydrilla/proxy/self_doc/popup.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/repositories.html.jinja (renamed from src/hydrilla/proxy/self_doc/repositories.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/script_blocking.html.jinja (renamed from src/hydrilla/proxy/self_doc/script_blocking.html.jinja)0
-rw-r--r--src/hydrilla/proxy/self_doc/en_US/url_patterns.html.jinja (renamed from src/hydrilla/proxy/self_doc/url_patterns.html.jinja)0
-rw-r--r--src/hydrilla/proxy/web_ui/root.py8
-rw-r--r--src/hydrilla/translations.py8
11 files changed, 13 insertions, 11 deletions
diff --git a/src/hydrilla/proxy/self_doc.py b/src/hydrilla/proxy/self_doc.py
index 838df57..eb5e9fd 100644
--- a/src/hydrilla/proxy/self_doc.py
+++ b/src/hydrilla/proxy/self_doc.py
@@ -16,6 +16,12 @@ loader = jinja2.PackageLoader(__package__, package_path='self_doc')
suffix_len = len('.html.jinja')
page_names = frozenset(
path.name[:-suffix_len]
- for path in (here / 'self_doc').glob('*.html.jinja')
+ for path in (here / 'self_doc/en_US').glob('*.html.jinja')
if path.name != 'doc_base.html.jinja'
)
+
+available_locales = tuple(
+ path.name
+ for path in (here / 'self_doc').iterdir()
+ if path.is_dir()
+)
diff --git a/src/hydrilla/proxy/self_doc/advanced_ui_features.html.jinja b/src/hydrilla/proxy/self_doc/en_US/advanced_ui_features.html.jinja
index 045309b..045309b 100644
--- a/src/hydrilla/proxy/self_doc/advanced_ui_features.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/advanced_ui_features.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/doc_index.html.jinja b/src/hydrilla/proxy/self_doc/en_US/doc_index.html.jinja
index 03f2231..03f2231 100644
--- a/src/hydrilla/proxy/self_doc/doc_index.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/doc_index.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/packages.html.jinja b/src/hydrilla/proxy/self_doc/en_US/packages.html.jinja
index 23e6f45..23e6f45 100644
--- a/src/hydrilla/proxy/self_doc/packages.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/packages.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/policy_selection.html.jinja b/src/hydrilla/proxy/self_doc/en_US/policy_selection.html.jinja
index 687d2bd..687d2bd 100644
--- a/src/hydrilla/proxy/self_doc/policy_selection.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/policy_selection.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/popup.html.jinja b/src/hydrilla/proxy/self_doc/en_US/popup.html.jinja
index a5ad909..a5ad909 100644
--- a/src/hydrilla/proxy/self_doc/popup.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/popup.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/repositories.html.jinja b/src/hydrilla/proxy/self_doc/en_US/repositories.html.jinja
index 4cf6d2c..4cf6d2c 100644
--- a/src/hydrilla/proxy/self_doc/repositories.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/repositories.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/script_blocking.html.jinja b/src/hydrilla/proxy/self_doc/en_US/script_blocking.html.jinja
index c0a5275..c0a5275 100644
--- a/src/hydrilla/proxy/self_doc/script_blocking.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/script_blocking.html.jinja
diff --git a/src/hydrilla/proxy/self_doc/url_patterns.html.jinja b/src/hydrilla/proxy/self_doc/en_US/url_patterns.html.jinja
index f3415c5..f3415c5 100644
--- a/src/hydrilla/proxy/self_doc/url_patterns.html.jinja
+++ b/src/hydrilla/proxy/self_doc/en_US/url_patterns.html.jinja
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index 4eea860..4915e51 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -188,14 +188,10 @@ def home_doc(page: str) -> str:
if page not in self_doc.page_names:
flask.abort(404)
- locale = translations.select_best_locale()
- if locale == translations.default_locale:
- prefix = ''
- else:
- prefix = f'{locale}/'
+ locale = translations.select_best_locale(self_doc.available_locales)
return flask.render_template(
- f'{prefix}{page}.html.jinja',
+ f'{locale}/{page}.html.jinja',
doc_output = 'html_hkt_mitm_it'
)
diff --git a/src/hydrilla/translations.py b/src/hydrilla/translations.py
index 62c8c88..1ff8788 100644
--- a/src/hydrilla/translations.py
+++ b/src/hydrilla/translations.py
@@ -39,7 +39,7 @@ supported_locales = [f.name for f in localedir.iterdir() if f.is_dir()]
default_locale = 'en_US'
-def select_best_locale() -> str:
+def select_best_locale(supported: t.Iterable[str] = supported_locales) -> str:
"""
....
@@ -56,8 +56,8 @@ def select_best_locale() -> str:
if use_flask:
best = flask.request.accept_languages.best_match(
- supported_locales,
- default=default_locale
+ supported,
+ default = default_locale
)
assert best is not None
return best
@@ -72,7 +72,7 @@ def select_best_locale() -> str:
except:
pass
- return locale if locale in supported_locales else default_locale
+ return locale if locale in supported else default_locale
translations: t.Dict[str, gettext.NullTranslations] = {}