Skip to content

Commit 2133325

Browse files
committed
Remove translators number
It's incorrect. Ref. python-docs-translations/transifex-automations#155
1 parent 3fa4c2e commit 2133325

File tree

3 files changed

+3
-44
lines changed

3 files changed

+3
-44
lines changed

README.en.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
Polish Translation of Python Documentation
22
==========================================
33
<!-- [[[cog
4-
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher, get_number_of_translators
4+
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher
55
66
stats = get_resource_language_stats()
77
total_words, total_strings = progress_from_resources(stats)
8-
translators = get_number_of_translators()
98
109
print(
1110
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)
1211
[![Total Translation of Documentation](https://img.shields.io/badge/total_words-{total_words:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
1312
[![Total Translation of Documentation](https://img.shields.io/badge/total_strings-{total_strings:.2f}%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
14-
![{translators} Translators](https://img.shields.io/badge/Translators-{translators}-0.svg)''')
1513
]]] -->
1614
[![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)
1715
[![Total Translation of Documentation](https://img.shields.io/badge/total_words-5.41%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
1816
[![Total Translation of Documentation](https://img.shields.io/badge/total_strings-12.57%25-0.svg)](https://python-docs-translations.github.io/dashboard/)
19-
![3 Translators](https://img.shields.io/badge/Translators-3-0.svg)
2017
<!-- [[[end]]] -->
2118

2219
*Przeczytaj to w innym języku: [polski](README.md)*

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
Polskie tłumaczenie dokumentacji Pythona
22
========================================
33
<!-- [[[cog
4-
from manage_translation import get_resource_language_stats, progress_from_resources, get_number_of_translators
4+
from manage_translation import get_resource_language_stats, progress_from_resources
55
66
stats = get_resource_language_stats()
77
total_words, total_strings = progress_from_resources(stats)
8-
translators = get_number_of_translators()
98
109
print(
1110
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)
1211
[![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/)
1312
[![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/)
14-
![{translators} tłumaczy](https://img.shields.io/badge/tłumaczy-{translators}-0.svg)''')
1513
]]] -->
1614
[![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)
1715
[![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/)
1816
[![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/)
19-
![3 tłumaczy](https://img.shields.io/badge/tłumaczy-3-0.svg)
2017
<!-- [[[end]]] -->
2118

2219
*Read this in another language: [English](README.en.md)*

manage_translation.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
import os
1818
from contextlib import chdir
1919
from dataclasses import dataclass
20-
from difflib import SequenceMatcher
21-
from logging import info
2220
from pathlib import Path
2321
from subprocess import call, run, CalledProcessError
2422
import sys
2523
from tempfile import TemporaryDirectory
26-
from typing import Self, Generator, Iterable
24+
from typing import Self, Iterable
2725
from warnings import warn
2826

2927
from polib import pofile, POFile
@@ -163,39 +161,6 @@ def progress_from_resources(
163161
)
164162

165163

166-
def get_number_of_translators():
167-
translators = set(_fetch_translators())
168-
_remove_bot(translators)
169-
translators = _eliminate_aliases(translators)
170-
return len(translators)
171-
172-
173-
def _fetch_translators() -> Generator[str, None, None]:
174-
for file in Path().rglob('*.po'):
175-
header = pofile(file).header.splitlines()
176-
for translator_record in header[header.index('Translators:') + 1 :]:
177-
translator, _year = translator_record.split(', ')
178-
yield translator
179-
180-
181-
def _remove_bot(translators: set[str]) -> None:
182-
translators.remove('Transifex Bot <>')
183-
184-
185-
def _eliminate_aliases(translators: set[str]) -> set[str]:
186-
unique = set()
187-
for name in translators:
188-
for match in unique:
189-
if (
190-
ratio := SequenceMatcher(lambda x: x in '<>@', name, match).ratio()
191-
) > 0.64:
192-
info(f'{name} and {match} are similar ({ratio:.3f}). Deduplicating.')
193-
break
194-
else:
195-
unique.add(name)
196-
return unique
197-
198-
199164
def language_switcher(entry: ResourceLanguageStatistics) -> bool:
200165
language_switcher_resources_prefixes = ('bugs', 'tutorial', 'library--functions')
201166
return any(

0 commit comments

Comments
 (0)