9
9
#
10
10
# * fetch: fetch translations from transifex.com and strip source lines from the
11
11
# files.
12
- # * recreate_readme: recreate readme to update translation progress.
13
12
# * regenerate_tx_config: recreate configuration for all resources.
14
13
15
14
from argparse import ArgumentParser
@@ -153,22 +152,22 @@ def _get_resources() -> list[Resource]:
153
152
return [Resource .from_api_v3_entry (entry ) for entry in resources ]
154
153
155
154
156
- def _get_resource_language_stats () -> list [ResourceLanguageStatistics ]:
155
+ def get_resource_language_stats () -> list [ResourceLanguageStatistics ]:
157
156
resources = _get_from_api_v3_with_cursor (
158
157
'https://rest.api.transifex.com/resource_language_stats' ,
159
158
{'filter[project]' : f'o:python-doc:p:{ PROJECT_SLUG } ' , 'filter[language]' : f'l:{ LANGUAGE } ' }
160
159
)
161
160
return [ResourceLanguageStatistics .from_api_v3_entry (entry ) for entry in resources ]
162
161
163
162
164
- def _progress_from_resources (resources : list [ResourceLanguageStatistics ], filter_function : Callable ):
163
+ def progress_from_resources (resources : list [ResourceLanguageStatistics ], filter_function : Callable ) -> float :
165
164
filtered = filter (filter_function , resources )
166
165
pairs = ((e .translated_words , e .total_words ) for e in filtered )
167
166
translated_total , total_total = (sum (counts ) for counts in zip (* pairs ))
168
167
return translated_total / total_total * 100
169
168
170
169
171
- def _get_number_of_translators ():
170
+ def get_number_of_translators ():
172
171
process = run (
173
172
['grep' , '-ohP' , r'(?<=^# )(.+)(?=, \d+$)' , '-r' , '.' ],
174
173
capture_output = True ,
@@ -179,82 +178,13 @@ def _get_number_of_translators():
179
178
return len (unique_translators )
180
179
181
180
182
- def recreate_readme ():
183
- def language_switcher (entry : ResourceLanguageStatistics ) -> bool :
184
- language_switcher_resources_prefixes = ('bugs' , 'tutorial' , 'library--functions' )
185
- return any (entry .name .startswith (prefix ) for prefix in language_switcher_resources_prefixes )
186
-
187
- resources = _get_resource_language_stats ()
188
- language_switcher_status = _progress_from_resources (resources , language_switcher )
189
- total_progress_status = _progress_from_resources (resources , lambda _ : True )
190
- number_of_translators = _get_number_of_translators ()
191
-
192
- with open ('README.md' , 'w' ) as file :
193
- file .write (
194
- f'''\
195
- Polskie tłumaczenie dokumentacji Pythona
196
- ========================================
197
- 
198
- 
199
- 
200
- 
201
-
202
- Jeśli znalazłeś(-aś) błąd lub masz sugestię,
203
- [dodaj zgłoszenie](https://github.com/python/python-docs-pl/issues) w tym projekcie lub
204
- napraw go sam(a):
205
-
206
- * Zarejestruj się na platformie [Transifex](https://www.transifex.com/) i wejdź na stronę
207
- projektu [dokumentacji Pythona](https://www.transifex.com/python-doc/python-newest/).
208
- * Na stronie projektu wybierz język polski.
209
- * Naciśnij przycisk „Join this Team”, aby dołączyć do zespołu.
210
- * Po dołączeniu do zespołu, wybierz zasób, który chcesz poprawić/zaktualizować.
211
-
212
- Więcej informacji o używaniu Transifeksa znajdziesz w
213
- [jego dokumentacji](https://docs.transifex.com/getting-started-1/translators).
214
-
215
- **Postęp tłumaczenia**
216
-
217
- 
218
-
219
- Język polski pojawi się w przełączniku języków na docs.python.org,
220
- [kiedy w pełni przetłumaczone będą](https://www.python.org/dev/peps/pep-0545/#add-translation-to-the-language-switcher):
221
- * `bugs`,
222
- * wszystkie zasoby z katalogu `tutorial`,
223
- * `library/functions`.
224
-
225
- **Jak obejrzeć najnowszy build dokumentacji?**
226
-
227
- Pobierz ostatnią zbudowaną dokumentację z listy artefaktów w ostatniej GitHub Action (zakładka Actions).
228
- Tłumaczenia pobierane są z Transifeksa do tego repozytorium co około pół godziny.
229
- Dokumentacja na python.org aktualizowana jest około raz dziennie.
230
-
231
- **Kanały komunikacji**
232
-
233
- * [python-docs-pl Discord](https://discord.gg/3faJmGKhta)
234
- * [Python translations working group](https://mail.python.org/mailman3/lists/translation.python.org/)
235
- * [Python Documentation Special Interest Group](https://www.python.org/community/sigs/current/doc-sig/)
236
-
237
- **Licencja**
238
-
239
- Zapraszając do współtworzenia projektu na platformie Transifex, proponujemy umowę na
240
- przekazanie twoich tłumaczeń Python Software Foundation
241
- [na licencji CC0](https://creativecommons.org/publicdomain/zero/1.0/deed.pl).
242
- W zamian będzie widoczne, że jesteś tłumaczem(-ką) części, którą przetłumaczyłeś(-łaś).
243
- Wyrażasz akceptację tej umowy przesyłając swoją pracę do włączenia do dokumentacji.
244
-
245
- **Aktualizacja tłumaczeń**
246
- * `./manage_translation.py recreate_tx_config`
247
- * `./manage_translation.py fetch`
248
- * `./manage_translation.py recreate_readme`
249
-
250
- **Potencjalnie przydatne materiały**
251
- * [polskie tłumaczenie dokumentacji Pythona 2.3](https://pl.python.org/docs/).
252
- '''
253
- )
181
+ def language_switcher (entry : ResourceLanguageStatistics ) -> bool :
182
+ language_switcher_resources_prefixes = ('bugs' , 'tutorial' , 'library--functions' )
183
+ return any (entry .name .startswith (prefix ) for prefix in language_switcher_resources_prefixes )
254
184
255
185
256
186
if __name__ == "__main__" :
257
- RUNNABLE_SCRIPTS = ('fetch' , 'recreate_tx_config' , 'recreate_readme' )
187
+ RUNNABLE_SCRIPTS = ('fetch' , 'recreate_tx_config' )
258
188
259
189
parser = ArgumentParser ()
260
190
parser .add_argument ('cmd' , choices = RUNNABLE_SCRIPTS )
0 commit comments