diff --git a/.github/workflows/update-lint-and-build.yml b/.github/workflows/update-lint-and-build.yml index 70dbecf4a4..e5915c7afa 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 -rP 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 8d6d3cef2f..783684849c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,24 @@ 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..11ad8a2a27 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 @@ -153,7 +152,7 @@ def _get_resources() -> list[Resource]: return [Resource.from_api_v3_entry(entry) for entry in resources] -def _get_resource_language_stats() -> list[ResourceLanguageStatistics]: +def get_resource_language_stats() -> list[ResourceLanguageStatistics]: resources = _get_from_api_v3_with_cursor( 'https://rest.api.transifex.com/resource_language_stats', {'filter[project]': f'o:python-doc:p:{PROJECT_SLUG}', 'filter[language]': f'l:{LANGUAGE}'} @@ -161,14 +160,14 @@ def _get_resource_language_stats() -> list[ResourceLanguageStatistics]: return [ResourceLanguageStatistics.from_api_v3_entry(entry) for entry in resources] -def _progress_from_resources(resources: list[ResourceLanguageStatistics], filter_function: Callable): +def progress_from_resources(resources: list[ResourceLanguageStatistics], filter_function: Callable) -> float: 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)) return translated_total / total_total * 100 -def _get_number_of_translators(): +def get_number_of_translators(): process = run( ['grep', '-ohP', r'(?<=^# )(.+)(?=, \d+$)', '-r', '.'], capture_output=True, @@ -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)