Skip to content

Commit

Permalink
feat: add --lang switch and update en template (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio authored Jul 24, 2024
1 parent 5a20b16 commit 1e6943c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
14 changes: 11 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def status(gh):
print(f"{issue.state}\t{issue.updated_at.isoformat()}\t{issue.html_url}")


def run(gh, since, dry_run):
def run(gh, since, dry_run, lang):
environment = jinja2.Environment(loader=jinja2.FileSystemLoader("templates/"))
template = environment.get_template("github/issue.it.tpl.txt")
template = environment.get_template(f"github/issue.{lang}.tpl.txt")

issues_created = 0
issues_updated = 0
Expand Down Expand Up @@ -267,6 +267,14 @@ def main():
default=False,
help="Don't actually create or update issues, just print",
)
parser.add_argument(
"--lang",
action="store",
dest="lang",
choices=["en", "it"],
default="en",
help="Use this language for the issues. (default: en)",
)

subparsers = parser.add_subparsers(dest="command")
subparsers.add_parser("status")
Expand All @@ -281,7 +289,7 @@ def main():
if args.command == "status":
status(gh)
else:
run(gh, args.since, args.dry_run)
run(gh, args.since, args.dry_run, args.lang)


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions templates/github/issue.en.tpl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ There are errors in the `publiccode.yml` file:

<pre>
<samp>
# Aggiungi questo a .github/workflows/publiccode-validation.yml
# Copy this to .github/workflows/publiccode-validation.yml
#
on: [pull_request]

Expand Down Expand Up @@ -50,15 +50,12 @@ jobs:
</p>
</details>

{{ debug }}
<!-- {{ debug }} -->

**Not sure what to do?**

Join [https://slack.developers.italia.it][https://slack.developers.italia.it] and ask in
the #publiccode channel or head to [https://forum.italia.it](Forum Italia).
Join [https://slack.developers.italia.it](https://slack.developers.italia.it) and ask in the #publiccode channel or head to [Forum Italia](https://forum.italia.it).

Your publiccode.yml validator bot.

<sub>[:link: Developers Italia](https://developers.italia.it/it/riuso/pubblicazione) | [:page_facing_up: publiccode.yml format](https://yml.publiccode.tools)i | [:information_source: My source code](https://github.com/italia/publiccode-issueopener)</sub>
<sub>[:link: Developers Italia](https://developers.italia.it/en/reuse/publication) | [:page_facing_up: publiccode.yml format](https://yml.publiccode.tools)i | [:information_source: My source code](https://github.com/italia/publiccode-issueopener) | [*]({{ api_log_url }})</sub>

<!-- **commands** -->

0 comments on commit 1e6943c

Please sign in to comment.