From 88ba4d7801f330c7034577576420a31f9673c167 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 14 Mar 2023 13:43:21 +0100 Subject: [PATCH 1/8] Switch to cog-powered README --- README.md | 14 ++++++++ manage_translation.py | 78 +++---------------------------------------- 2 files changed, 18 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 8d6d3cef2f..9c08f0fa62 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,23 @@ Polskie tłumaczenie dokumentacji Pythona ======================================== ![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) + ![48.35% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-48.35%25-0.svg) ![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-3.51%25-0.svg) ![19 tłumaczy](https://img.shields.io/badge/tłumaczy-19-0.svg) + Jeśli znalazłeś(-aś) błąd lub masz sugestię, [dodaj zgłoszenie](https://github.com/python/python-docs-pl/issues) w tym projekcie lub diff --git a/manage_translation.py b/manage_translation.py index 82e046cfb4..13b7943eea 100755 --- a/manage_translation.py +++ b/manage_translation.py @@ -9,7 +9,6 @@ # # * fetch: fetch translations from transifex.com and strip source lines from the # files. -# * recreate_readme: recreate readme to update translation progress. # * regenerate_tx_config: recreate configuration for all resources. from argparse import ArgumentParser @@ -179,82 +178,13 @@ def _get_number_of_translators(): return len(unique_translators) -def recreate_readme(): - def language_switcher(entry: ResourceLanguageStatistics) -> bool: - language_switcher_resources_prefixes = ('bugs', 'tutorial', 'library--functions') - return any(entry.name.startswith(prefix) for prefix in language_switcher_resources_prefixes) - - resources = _get_resource_language_stats() - language_switcher_status = _progress_from_resources(resources, language_switcher) - total_progress_status = _progress_from_resources(resources, lambda _: True) - number_of_translators = _get_number_of_translators() - - with open('README.md', 'w') as file: - file.write( - f'''\ -Polskie tłumaczenie dokumentacji Pythona -======================================== -![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) -![{language_switcher_status:.2f}% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-{language_switcher_status:.2f}%25-0.svg) -![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-{total_progress_status:.2f}%25-0.svg) -![{number_of_translators} tłumaczy](https://img.shields.io/badge/tłumaczy-{number_of_translators}-0.svg) - -Jeśli znalazłeś(-aś) błąd lub masz sugestię, -[dodaj zgłoszenie](https://github.com/python/python-docs-pl/issues) w tym projekcie lub -napraw go sam(a): - -* Zarejestruj się na platformie [Transifex](https://www.transifex.com/) i wejdź na stronę -projektu [dokumentacji Pythona](https://www.transifex.com/python-doc/python-newest/). -* Na stronie projektu wybierz język polski. -* Naciśnij przycisk „Join this Team”, aby dołączyć do zespołu. -* Po dołączeniu do zespołu, wybierz zasób, który chcesz poprawić/zaktualizować. - -Więcej informacji o używaniu Transifeksa znajdziesz w -[jego dokumentacji](https://docs.transifex.com/getting-started-1/translators). - -**Postęp tłumaczenia** - -![postęp tłumaczenia do przełącznika języków](language-switcher-progress.svg) - -Język polski pojawi się w przełączniku języków na docs.python.org, -[kiedy w pełni przetłumaczone będą](https://www.python.org/dev/peps/pep-0545/#add-translation-to-the-language-switcher): -* `bugs`, -* wszystkie zasoby z katalogu `tutorial`, -* `library/functions`. - -**Jak obejrzeć najnowszy build dokumentacji?** - -Pobierz ostatnią zbudowaną dokumentację z listy artefaktów w ostatniej GitHub Action (zakładka Actions). -Tłumaczenia pobierane są z Transifeksa do tego repozytorium co około pół godziny. -Dokumentacja na python.org aktualizowana jest około raz dziennie. - -**Kanały komunikacji** - -* [python-docs-pl Discord](https://discord.gg/3faJmGKhta) -* [Python translations working group](https://mail.python.org/mailman3/lists/translation.python.org/) -* [Python Documentation Special Interest Group](https://www.python.org/community/sigs/current/doc-sig/) - -**Licencja** - -Zapraszając do współtworzenia projektu na platformie Transifex, proponujemy umowę na -przekazanie twoich tłumaczeń Python Software Foundation -[na licencji CC0](https://creativecommons.org/publicdomain/zero/1.0/deed.pl). -W zamian będzie widoczne, że jesteś tłumaczem(-ką) części, którą przetłumaczyłeś(-łaś). -Wyrażasz akceptację tej umowy przesyłając swoją pracę do włączenia do dokumentacji. - -**Aktualizacja tłumaczeń** -* `./manage_translation.py recreate_tx_config` -* `./manage_translation.py fetch` -* `./manage_translation.py recreate_readme` - -**Potencjalnie przydatne materiały** -* [polskie tłumaczenie dokumentacji Pythona 2.3](https://pl.python.org/docs/). -''' - ) +def language_switcher(entry: ResourceLanguageStatistics) -> bool: + language_switcher_resources_prefixes = ('bugs', 'tutorial', 'library--functions') + return any(entry.name.startswith(prefix) for prefix in language_switcher_resources_prefixes) if __name__ == "__main__": - RUNNABLE_SCRIPTS = ('fetch', 'recreate_tx_config', 'recreate_readme') + RUNNABLE_SCRIPTS = ('fetch', 'recreate_tx_config') parser = ArgumentParser() parser.add_argument('cmd', choices=RUNNABLE_SCRIPTS) From ac14c85561090ed96240bb7dcdc723739584e70f Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 14 Mar 2023 13:50:38 +0100 Subject: [PATCH 2/8] Use cog in GitHub Actions, add checksum --- .github/workflows/update-lint-and-build.yml | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-lint-and-build.yml b/.github/workflows/update-lint-and-build.yml index 70dbecf4a4..c826655d7c 100644 --- a/.github/workflows/update-lint-and-build.yml +++ b/.github/workflows/update-lint-and-build.yml @@ -19,7 +19,7 @@ jobs: with: python-version: 3 - run: sudo apt-get install -y gettext - - run: pip install requests + - run: pip install requests cogapp - uses: actions/checkout@master with: ref: ${{ matrix.version }} @@ -31,7 +31,7 @@ jobs: - run: ./manage_translation.py fetch env: TX_TOKEN: ${{ secrets.TX_TOKEN }} - - run: ./manage_translation.py recreate_readme + - run: cog -crP README.md env: TX_TOKEN: ${{ secrets.TX_TOKEN }} - run: git config --local user.email github-actions@github.com diff --git a/README.md b/README.md index 9c08f0fa62..401ca7e951 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ f'''![{switcher:.2f}% przełącznika języków](https://img.shields.io/badge/prz ![48.35% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-48.35%25-0.svg) ![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-3.51%25-0.svg) ![19 tłumaczy](https://img.shields.io/badge/tłumaczy-19-0.svg) - + Jeśli znalazłeś(-aś) błąd lub masz sugestię, [dodaj zgłoszenie](https://github.com/python/python-docs-pl/issues) w tym projekcie lub From c6ea6eb056d554eaf62039682ee51bad1c37bbcd Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 14 Mar 2023 14:04:50 +0100 Subject: [PATCH 3/8] Make public functions public --- README.md | 10 +++++----- manage_translation.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 401ca7e951..5dcad81ebe 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ Polskie tłumaczenie dokumentacji Pythona ======================================== ![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) +![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) ![48.35% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-48.35%25-0.svg) ![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-3.51%25-0.svg) ![19 tłumaczy](https://img.shields.io/badge/tłumaczy-19-0.svg) - + Jeśli znalazłeś(-aś) błąd lub masz sugestię, [dodaj zgłoszenie](https://github.com/python/python-docs-pl/issues) w tym projekcie lub From 318763a512e672f173d30f9020a8f0a6a62d2123 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 14 Mar 2023 22:49:11 +0100 Subject: [PATCH 5/8] Fixes after rebase --- README.md | 5 ++--- manage_translation.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 783684849c..8d91c1776c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ Polskie tłumaczenie dokumentacji Pythona ======================================== ![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) diff --git a/manage_translation.py b/manage_translation.py index 72fe4d1b16..169f7b8be3 100755 --- a/manage_translation.py +++ b/manage_translation.py @@ -167,7 +167,7 @@ def _progress_from_resources(resources: list[ResourceLanguageStatistics], filter return translated_total / total_total * 100 -def progress_from_resources(resources: list[ResourceLanguageStatistics], filter_function: Callable): +def progress_from_resources(resources, filter_function): filtered = filter(filter_function, resources) pairs = ((e.translated_words, e.total_words) for e in filtered) translated_total, total_total = (sum(counts) for counts in zip(*pairs)) From 7221295906a035c3c62eb589299b351530e39d63 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 15 Mar 2023 22:53:30 +0100 Subject: [PATCH 6/8] Fixes after rebase --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d91c1776c..3dd053260e 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,13 @@ from manage_translation import get_resource_language_stats, progress_from_resour stats = get_resource_language_stats() switcher = progress_from_resources(stats, language_switcher) +total = progress_from_resources(stats, lambda _: True) translators = get_number_of_translators() print( f'''![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) ![{switcher:.2f}% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-{switcher:.2f}%25-0.svg) -![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/dynamic/json.svg?label=całość&query=$.{LANGUAGE}&url=http://gce.zhsj.me/python/newest) +![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-{total:.2f}%25-0.svg) ![{translators} tłumaczy](https://img.shields.io/badge/tłumaczy-{translators}-0.svg)''') ]]] --> ![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg) From 2e9192a30075eadc518e1ab4d556476047b73b64 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 15 Mar 2023 22:54:51 +0100 Subject: [PATCH 7/8] Remove now unused import --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3dd053260e..783684849c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Polskie tłumaczenie dokumentacji Pythona ========================================