Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/update-lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
Polskie tłumaczenie dokumentacji Pythona
========================================
<!-- [[[cog
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher, get_number_of_translators

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/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)
![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)
<!-- [[[end]]] -->

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
Expand Down
84 changes: 7 additions & 77 deletions manage_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -153,22 +152,22 @@ 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}'}
)
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,
Expand All @@ -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)
Expand Down