From 1e6943ce2c33d7893c5b6225ca0e9fe66f74b309 Mon Sep 17 00:00:00 2001
From: Fabio Bonelli
Date: Wed, 24 Jul 2024 12:26:27 +0200
Subject: [PATCH] feat: add --lang switch and update en template (#23)
---
main.py | 14 +++++++++++---
templates/github/issue.en.tpl.txt | 11 ++++-------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/main.py b/main.py
index 89c74b8..892ece3 100755
--- a/main.py
+++ b/main.py
@@ -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
@@ -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")
@@ -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__":
diff --git a/templates/github/issue.en.tpl.txt b/templates/github/issue.en.tpl.txt
index 046c2fc..2877ac1 100644
--- a/templates/github/issue.en.tpl.txt
+++ b/templates/github/issue.en.tpl.txt
@@ -18,7 +18,7 @@ There are errors in the `publiccode.yml` file:
-# Aggiungi questo a .github/workflows/publiccode-validation.yml
+# Copy this to .github/workflows/publiccode-validation.yml
#
on: [pull_request]
@@ -50,15 +50,12 @@ jobs:
-{{ 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.
-
-[: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)
+[: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 }})