You've already forked snikket-web-portal
Compare commits
1 Commits
feature/va
...
feature/ci
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b84b84b394 |
23
.github/workflows/main.yaml
vendored
23
.github/workflows/main.yaml
vendored
@@ -50,6 +50,29 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m flake8 snikket_web
|
python -m flake8 snikket_web
|
||||||
|
|
||||||
|
translation-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
name: 'lint: i18n'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.9'
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
pip install flask-babel
|
||||||
|
- name: Linting
|
||||||
|
run: |
|
||||||
|
sed -ri '/^"POT-Creation-Date: /d' snikket_web/translations/messages.pot
|
||||||
|
git add snikket_web/translations/messages.pot
|
||||||
|
make extract_translations
|
||||||
|
sed -ri '/^"POT-Creation-Date: /d' snikket_web/translations/messages.pot
|
||||||
|
git diff --exit-code --color -- snikket_web/translations/messages.pot
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import quart.flask_patch # noqa:F401
|
|||||||
from quart import (
|
from quart import (
|
||||||
current_app,
|
current_app,
|
||||||
request,
|
request,
|
||||||
g,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
import flask_babel
|
import flask_babel
|
||||||
@@ -35,9 +34,6 @@ BYTE_UNIT_SCALE_MAP = [
|
|||||||
|
|
||||||
@babel.localeselector # type:ignore
|
@babel.localeselector # type:ignore
|
||||||
def selected_locale() -> str:
|
def selected_locale() -> str:
|
||||||
# Needs mypy ignore because this is a free-for-all object and has no
|
|
||||||
# publicly known attributes.
|
|
||||||
g.language_header_accessed = True # type: ignore
|
|
||||||
selected = request.accept_languages.best_match(
|
selected = request.accept_languages.best_match(
|
||||||
current_app.config['LANGUAGES']
|
current_app.config['LANGUAGES']
|
||||||
) or current_app.config['LANGUAGES'][0]
|
) or current_app.config['LANGUAGES'][0]
|
||||||
@@ -72,12 +68,6 @@ def format_bytes(n: float) -> str:
|
|||||||
return "{} {}".format(n, unit)
|
return "{} {}".format(n, unit)
|
||||||
|
|
||||||
|
|
||||||
def add_vary_language_header(resp: quart.Response) -> quart.Response:
|
|
||||||
if getattr(g, "language_header_accessed", False):
|
|
||||||
resp.vary.add("Accept-Language")
|
|
||||||
return resp
|
|
||||||
|
|
||||||
|
|
||||||
def init_templating(app: quart.Quart) -> None:
|
def init_templating(app: quart.Quart) -> None:
|
||||||
app.template_filter("repr")(repr)
|
app.template_filter("repr")(repr)
|
||||||
app.template_filter("format_datetime")(flask_babel.format_datetime)
|
app.template_filter("format_datetime")(flask_babel.format_datetime)
|
||||||
@@ -88,7 +78,6 @@ def init_templating(app: quart.Quart) -> None:
|
|||||||
app.template_filter("format_bytes")(format_bytes)
|
app.template_filter("format_bytes")(format_bytes)
|
||||||
app.template_filter("flatten")(flatten)
|
app.template_filter("flatten")(flatten)
|
||||||
app.template_filter("circle_name")(circle_name)
|
app.template_filter("circle_name")(circle_name)
|
||||||
app.after_request(add_vary_language_header)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_error_id() -> str:
|
def generate_error_id() -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user