diff --git a/README.en.md b/README.en.md index 709faac6b..80be79893 100644 --- a/README.en.md +++ b/README.en.md @@ -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) diff --git a/README.md b/README.md index 0d8c09991..4653311d8 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/manage_translation.py b/manage_translation.py index 7d53b2f23..e8a042a6a 100755 --- a/manage_translation.py +++ b/manage_translation.py @@ -29,6 +29,8 @@ from transifex.api import transifex_api LANGUAGE = 'pl' +PROJECT_SLUG = 'python-newest' +VERSION = '3.14' def fetch(): @@ -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. @@ -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():