Skip to content

Commit

Permalink
wip: extract pot
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Jan 20, 2025
1 parent 285c7c2 commit 85cb4dc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ questionpy-server = { git = "https://github.com/questionpy-org/questionpy-server
jinja2 = "^3.1.3"
aiohttp-jinja2 = "^1.6"
lxml = "~5.1.0"
babel = "^2.16.0"

[tool.poetry.group.dev.dependencies]
types-PyYAML = "^6.0.12.20240311"
Expand Down
2 changes: 2 additions & 0 deletions questionpy_sdk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import click

from questionpy_sdk.commands.create import create
from questionpy_sdk.commands.i18n import i18n
from questionpy_sdk.commands.package import package
from questionpy_sdk.commands.repo import repo
from questionpy_sdk.commands.run import run
Expand Down Expand Up @@ -38,6 +39,7 @@ def cli(ctx: click.Context, *, verbose: bool, no_interaction: bool) -> None:
cli.add_command(package)
cli.add_command(run)
cli.add_command(repo)
cli.add_command(i18n)

if __name__ == "__main__":
cli()
26 changes: 26 additions & 0 deletions questionpy_sdk/commands/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import itertools
from pathlib import Path

import click

from questionpy_sdk.i18n import GettextTools

from babel.messages.extract import extract_from_dir


@click.group()

Check failure on line 11 in questionpy_sdk/commands/i18n.py

View workflow job for this annotation

GitHub Actions / ci / ruff-lint

Ruff (I001)

questionpy_sdk/commands/i18n.py:1:1: I001 Import block is un-sorted or un-formatted
def i18n() -> None:
pass

@i18n.command()

Check failure on line 15 in questionpy_sdk/commands/i18n.py

View workflow job for this annotation

GitHub Actions / ci / ruff-lint

Ruff (E302)

questionpy_sdk/commands/i18n.py:15:1: E302 Expected 2 blank lines, found 1
# TODO: Support extraction from already-zipped-up packages.
@click.argument("source", type=click.Path(exists=True, file_okay=False, path_type=Path))
@click.option("-o", "--output", type=click.Path(dir_okay=False, path_type=Path))
def extract(source: Path, output: Path | None) -> None:
tools = GettextTools()

extract_from_dir(source, )

inputs = [path for path in itertools.chain(source.glob("python/**/*"), source.glob("templates/**/*"))
if path.is_file()]
tools.extract_pot(inputs, output or "-")

0 comments on commit 85cb4dc

Please sign in to comment.