Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .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 cogapp
- run: pip install requests cogapp polib
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ f'''![build](https://github.com/python/python-docs-pl/workflows/.github/workflow
![build](https://github.com/python/python-docs-pl/workflows/.github/workflows/update-and-build.yml/badge.svg)
![48.18% przełącznika języków](https://img.shields.io/badge/przełącznik_języków-48.18%25-0.svg)
![postęp tłumaczenia całości dokumentacji](https://img.shields.io/badge/całość-3.50%25-0.svg)
![19 tłumaczy](https://img.shields.io/badge/tłumaczy-19-0.svg)
![18 tłumaczy](https://img.shields.io/badge/tłumaczy-18-0.svg)
<!-- [[[end]]] -->

Jeśli znalazłeś(-aś) błąd lub masz sugestię,
Expand Down
24 changes: 14 additions & 10 deletions manage_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
# * regenerate_tx_config: recreate configuration for all resources.

from argparse import ArgumentParser
from collections import Counter
import os
from dataclasses import dataclass
from pathlib import Path
from re import match
from subprocess import call, run
from subprocess import call
import sys
from typing import Self, Callable
from urllib.parse import urlparse, parse_qs

from polib import pofile

LANGUAGE = 'pl'


Expand Down Expand Up @@ -168,14 +170,16 @@ def progress_from_resources(resources: list[ResourceLanguageStatistics], filter_


def get_number_of_translators():
process = run(
['grep', '-ohP', r'(?<=^# )(.+)(?=, \d+$)', '-r', '.'],
capture_output=True,
text=True,
)
translators = [match('(.*)( <.*>)?', t).group(1) for t in process.stdout.splitlines()]
unique_translators = Counter(translators).keys()
return len(unique_translators)
translators = set()
for file in Path().rglob('*.po'):
header = pofile(file).header.splitlines()
for translator_record in header[header.index('Translators:') + 1:]:
translator, _ = translator_record.split(', ')
if (email_match := match('.* <(.*)>', translator)):
translators.add(email_match.group(1))
else:
translators.add(translator)
return len(translators)


def language_switcher(entry: ResourceLanguageStatistics) -> bool:
Expand Down