Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a number of nox -s translate issues. #1962

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ jobs:
- name: "Run accessibility tests with playwright 🎭"
# build PST, build docs, then run a11y-tests
run: python -Im tox run -e py312-docs,a11y-tests
nox-tests:
name: "nox tests (ubuntu-latest, 3.12)"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: "Run various nox commands"
# build PST, build docs, then run a11y-tests
run: |
pip install nox
nox -s translate -- init
nox -s translate -- extract
nox -s translate -- update
nox -s translate -- compile

# Build our docs (PST) on major OSes and check for warnings
build-site:
Expand Down
21 changes: 15 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def translate(session: nox.Session) -> None:
pybabel_cmd, found = (c, True)

if found is False:
print(
raise ValueError(
"No translate command found. Use like: `nox -s translate -- COMMAND`."
"\ndefaulting to `update`"
"\nAvailable commands: extract, update, compile, init"
Expand All @@ -166,18 +166,28 @@ def translate(session: nox.Session) -> None:
lan = "en" if len(session.posargs) < 2 else session.posargs[-1]

# get the path to the differnet local related pieces
locale_dir = str(ROOT / "src" / "pydata_sphinx_theme" / "locale")
locale_dir_p = ROOT / "src" / "pydata_sphinx_theme" / "locale"
locale_dir = str(locale_dir_p)
babel_cfg = str(ROOT / "babel.cfg")
pot_file = str(locale_dir / "sphinx.pot")
pot_file = str(locale_dir_p / "sphinx.pot")

# install deps
session.install("Babel")
session.install("jinja2")

# build the command from the parameters
cmd = ["pybabel", pybabel_cmd]

if pybabel_cmd == "extract":
cmd += [ROOT, "-F", babel_cfg, "-o", pot_file, "-k", "_ __ l_ lazy_gettext"]
cmd += [
str(ROOT),
"-F",
babel_cfg,
"-o",
pot_file,
"-k",
"_ __ l_ lazy_gettext",
]

elif pybabel_cmd == "update":
cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx"]
Expand All @@ -187,8 +197,7 @@ def translate(session: nox.Session) -> None:

elif pybabel_cmd == "init":
cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx", "-l", lan]

session.run(cmd)
session.run(*cmd)


@nox.session()
Expand Down
Loading