Skip to content

Commit f497c72

Browse files
authored
Script to find format differences (#1011)
1 parent 2db02b4 commit f497c72

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

distutils/setupscript.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ msgid ""
12251225
"The ``long_description`` field is used by PyPI when you publish a package, "
12261226
"to build its project page."
12271227
msgstr ""
1228-
"PyPI utiliza el campo ``descripción larga`` cuando publica un paquete para "
1228+
"PyPI utiliza el campo ``long_description`` cuando publica un paquete para "
12291229
"construir su página de proyecto."
12301230

12311231
#: ../Doc/distutils/setupscript.rst:621

scripts/format_differences.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import collections
2+
import os
3+
import glob
4+
5+
from pprint import pprint
6+
7+
import polib # fades
8+
9+
PO_DIR = os.path.abspath(
10+
os.path.join(
11+
os.path.dirname(__file__),
12+
'..',
13+
))
14+
15+
16+
17+
DELIMITERS = ("``", "*")
18+
19+
def has_delimiters(x):
20+
for d in DELIMITERS:
21+
if d in x:
22+
return True
23+
return False
24+
25+
def main():
26+
files_with_differences = collections.defaultdict(list)
27+
28+
for i, pofilename in enumerate(glob.glob(PO_DIR + '**/**/*.po')):
29+
po = polib.pofile(pofilename)
30+
if po.percent_translated() < 85:
31+
continue
32+
33+
for entry in po:
34+
words = []
35+
wordsid = wordsstr = list()
36+
37+
if has_delimiters(entry.msgid):
38+
wordsid = [word for word in entry.msgid.split() if has_delimiter(word)]
39+
40+
if has_delimiters(entry.msgstr):
41+
wordsstr = [word for word in entry.msgstr.split() if has_delimiter(word)]
42+
43+
if len(wordsid) != len(wordsstr):
44+
key = pofilename.replace(PO_DIR, '')
45+
files_with_differences[key].append({
46+
'occurrences': entry.occurrences,
47+
'words': {
48+
'original': wordsid,
49+
'translated': wordsstr,
50+
},
51+
})
52+
53+
return files_with_differences
54+
55+
56+
pprint(main())

0 commit comments

Comments
 (0)