From 492cfbe2ded340e4c8e7f4e45c82a61e4df31139 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 15 Dec 2021 23:17:42 -0300 Subject: [PATCH 1/3] Create list-translators.py --- list-translators.py | 73 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 list-translators.py diff --git a/list-translators.py b/list-translators.py new file mode 100644 index 000000000..2e8709b95 --- /dev/null +++ b/list-translators.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 +# Extract translation credits from the PO files within the directory + +from pathlib import Path + +# Get all PO files in the current directory and its subdirectories +p = Path(r'.').glob('**/*.po') +pofiles = list(p) + +translators_credits_list = [] + +# Exclude bot account, duplicated entry and hashes for deleted accounts +ignore_entries = [ + 'i17obot ', + 'Willian Lopes', + '01419cbcade949a3bc5433893a160e74', + '2c4b5a73177ea5ea1d3324f10df471a7_b8aeba7 <7df8a60bac356f3b148ac94f3c2796f6_834576>', + '82596da39877db21448335599650eb68_ac09920 <1d2e18e2f37f0ba6c4f06b239e0670bd_848591>', +] + +for po in pofiles: + with po.open() as f: + + # If true, it means it is between "# Translators:\n" and "#\n", + # and it is a translator credit. Start with False + is_translator_credits = False + + # Start looping through the file, line by line, looking for the + # translation credits block, and then quit without going any + # further down. + for line in f: + + # if true, translator credits block finished; quit file + if line == '#\n' and is_translator_credits: + break + + # if true, we are in the translator credits block; extract info + if is_translator_credits: + # remove leading sharp sign, and trailing comma and year + line = line.strip('# ') + line = line[:-7] + + # Skip entries we do not want to add + if line in ignore_entries: + continue + + # Add entry to the set + if line not in translators_credits_list: + translators_credits_list.append(line) + + # if true, this is the start of the translation credits block; + # flag is_translator_credits and go to the next line + if line == '# Translators:\n': + is_translator_credits = True + continue + + # if true, it means the loop went down until it found the first msgid. + # This means there is no translator credits block (i.e. no one started + # translating this file). Therefore we should stop looking at this file. + # Quit this file and go to the next one. + if line == 'msgid "': + break + +# Remove parentheses that messes the reorder of the list. +edit_index = translators_credits_list.index('(Douglas da Silva) ') +translators_credits_list[edit_index] = 'Douglas da Silva ' + +# Reordered in a case-insensitive way as some names were set lowercase +translators_credits_list_reordered = sorted(translators_credits_list, key=str.casefold) + +# Print the resulting list to the standard output +for t in translators_credits_list_reordered: + print(t) From f21afefe7e142e44a26bd166421214f7f6986e41 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 16 Dec 2021 05:57:57 -0300 Subject: [PATCH 2/3] chore: use set instead of list in list-translators --- list-translators.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/list-translators.py b/list-translators.py index 2e8709b95..1bf15a729 100644 --- a/list-translators.py +++ b/list-translators.py @@ -7,7 +7,7 @@ p = Path(r'.').glob('**/*.po') pofiles = list(p) -translators_credits_list = [] +translators_credits_set = set() # Exclude bot account, duplicated entry and hashes for deleted accounts ignore_entries = [ @@ -37,7 +37,7 @@ # if true, we are in the translator credits block; extract info if is_translator_credits: # remove leading sharp sign, and trailing comma and year - line = line.strip('# ') + line = line.strip('# ') line = line[:-7] # Skip entries we do not want to add @@ -45,11 +45,10 @@ continue # Add entry to the set - if line not in translators_credits_list: - translators_credits_list.append(line) + translators_credits_set.add(line) # if true, this is the start of the translation credits block; - # flag is_translator_credits and go to the next line + # flag is_translator_credits and go to the next line if line == '# Translators:\n': is_translator_credits = True continue @@ -61,13 +60,10 @@ if line == 'msgid "': break -# Remove parentheses that messes the reorder of the list. -edit_index = translators_credits_list.index('(Douglas da Silva) ') -translators_credits_list[edit_index] = 'Douglas da Silva ' - -# Reordered in a case-insensitive way as some names were set lowercase -translators_credits_list_reordered = sorted(translators_credits_list, key=str.casefold) +# Remove parentheses that messes the alphabeticall order. +translators_credits_set.remove('(Douglas da Silva) ') +translators_credits_set.add('Douglas da Silva ') # Print the resulting list to the standard output -for t in translators_credits_list_reordered: +for t in sorted(translators_credits_set): print(t) From eca32346fab2661e87dfbee9f8611a7fcfb6eb3d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 16 Dec 2021 06:20:55 -0300 Subject: [PATCH 3/3] chore: use a better shebang in list-translators --- list-translators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list-translators.py b/list-translators.py index 1bf15a729..8f7da8d81 100644 --- a/list-translators.py +++ b/list-translators.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # Extract translation credits from the PO files within the directory from pathlib import Path pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy