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
5 changes: 1 addition & 4 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
Polish Translation of Python Documentation
==========================================
<!-- [[[cog
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher, get_number_of_translators
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher
stats = get_resource_language_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_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)
[![Total Translation of Documentation](https://img.shields.io/badge/total_words-5.41%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
[![Total Translation of Documentation](https://img.shields.io/badge/total_strings-12.57%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
![3 Translators](https://img.shields.io/badge/Translators-3-0.svg)
<!-- [[[end]]] -->

*Przeczytaj to w innym języku: [polski](README.md)*
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
Polskie tłumaczenie dokumentacji Pythona
========================================
<!-- [[[cog
from manage_translation import get_resource_language_stats, progress_from_resources, get_number_of_translators
from manage_translation import get_resource_language_stats, progress_from_resources

stats = get_resource_language_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ść_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)
[![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość_słów-5.41%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-12.57%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
![3 tłumaczy](https://img.shields.io/badge/tłumaczy-3-0.svg)
<!-- [[[end]]] -->

*Read this in another language: [English](README.en.md)*
Expand Down
37 changes: 1 addition & 36 deletions manage_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import os
from contextlib import chdir
from dataclasses import dataclass
from difflib import SequenceMatcher
from logging import info
from pathlib import Path
from subprocess import call, run, CalledProcessError
import sys
from tempfile import TemporaryDirectory
from typing import Self, Generator, Iterable
from typing import Self, Iterable
from warnings import warn

from polib import pofile, POFile
Expand Down Expand Up @@ -163,39 +161,6 @@ def progress_from_resources(
)


def get_number_of_translators():
translators = set(_fetch_translators())
_remove_bot(translators)
translators = _eliminate_aliases(translators)
return len(translators)


def _fetch_translators() -> Generator[str, None, None]:
for file in Path().rglob('*.po'):
header = pofile(file).header.splitlines()
for translator_record in header[header.index('Translators:') + 1 :]:
translator, _year = translator_record.split(', ')
yield translator


def _remove_bot(translators: set[str]) -> None:
translators.remove('Transifex Bot <>')


def _eliminate_aliases(translators: set[str]) -> set[str]:
unique = set()
for name in translators:
for match in unique:
if (
ratio := SequenceMatcher(lambda x: x in '<>@', name, match).ratio()
) > 0.64:
info(f'{name} and {match} are similar ({ratio:.3f}). Deduplicating.')
break
else:
unique.add(name)
return unique


def language_switcher(entry: ResourceLanguageStatistics) -> bool:
language_switcher_resources_prefixes = ('bugs', 'tutorial', 'library--functions')
return any(
Expand Down
Loading