Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Increase progress and link #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2025
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
5 changes: 3 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Polish Translation of Python Documentation
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher, get_number_of_translators

stats = get_resource_language_stats()
total = progress_from_resources(stats)
total_words, total_strings = progress_from_resources(stats)
translators = get_number_of_translators()

print(
f'''[![build](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml/badge.svg)](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml)
![Total Translation of Documentation](https://img.shields.io/badge/Total-{total:.3f}%25-0.svg)
[![Total Translation of Documentation](https://img.shields.io/badge/total_words-{total_words:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
[![Total Translation of Documentation](https://img.shields.io/badge/total_strings-{total_strings:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
![{translators} Translators](https://img.shields.io/badge/Translators-{translators}-0.svg)''')
]]] -->
[![build](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml/badge.svg)](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Polskie tłumaczenie dokumentacji Pythona
from manage_translation import get_resource_language_stats, progress_from_resources, get_number_of_translators

stats = get_resource_language_stats()
total = progress_from_resources(stats)
total_words, total_strings = progress_from_resources(stats)
translators = get_number_of_translators()

print(
f'''[![build](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml/badge.svg)](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml)
![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-{total:.3f}%25-0.svg)
[![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość_słów-{total_words:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
[![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość_napisów-{total_strings:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
![{translators} tłumaczy](https://img.shields.io/badge/tłumaczy-{translators}-0.svg)''')
]]] -->
[![build](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml/badge.svg)](https://github.com/python/python-docs-pl/actions/workflows/update-lint-and-build.yml)
Expand Down
16 changes: 8 additions & 8 deletions manage_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from transifex.api import transifex_api

LANGUAGE = 'pl'
PROJECT_SLUG = 'python-newest'
VERSION = '3.14'


def fetch():
Expand All @@ -49,10 +51,6 @@ def _call(command: str):
exit(return_code)


PROJECT_SLUG = 'python-newest'
VERSION = '3.14'


def recreate_tx_config():
"""
Regenerate Transifex client config for all resources.
Expand Down Expand Up @@ -151,10 +149,12 @@ def get_resource_language_stats() -> list[ResourceLanguageStatistics]:
return [ResourceLanguageStatistics.from_api_entry(entry) for entry in resources]


def progress_from_resources(resources: Iterable[ResourceLanguageStatistics]) -> float:
pairs = ((e.translated_words, e.total_words) for e in resources)
translated_total, total_total = (sum(counts) for counts in zip(*pairs))
return translated_total / total_total * 100
def progress_from_resources(resources: Iterable[ResourceLanguageStatistics]) -> tuple[float, float]:
word_pairs = ((e.translated_words, e.total_words) for e in resources)
string_pairs = ((e.translated_strings, e.total_strings) for e in resources)
translated_total_words, total_words = (sum(counts) for counts in zip(*word_pairs))
translated_total_strs, total_strs = (sum(counts) for counts in zip(*string_pairs))
return translated_total_words / total_words * 100, translated_total_strs / total_strs * 100


def get_number_of_translators():
Expand Down