-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
def i18n() -> None: | ||
pass | ||
|
||
@i18n.command() | ||
# 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 "-") |