File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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
+ def main ():
17
+ files_with_differences = collections .defaultdict (list )
18
+
19
+ for i , pofilename in enumerate (glob .glob (PO_DIR + '**/**/*.po' )):
20
+ po = polib .pofile (pofilename )
21
+ if po .percent_translated () < 85 :
22
+ continue
23
+
24
+ for entry in po :
25
+ words = []
26
+ wordsid = wordsstr = list ()
27
+
28
+ if '*' in entry .msgid or '``' in entry .msgid :
29
+ wordsid = [word for word in entry .msgid .split () if '*' in word or '``' in word ]
30
+
31
+ if '*' in entry .msgstr or '``' in entry .msgstr :
32
+ wordsstr = [word for word in entry .msgstr .split () if '*' in word or '``' in word ]
33
+
34
+ if len (wordsid ) != len (wordsstr ):
35
+ key = pofilename .replace (PO_DIR , '' )
36
+ files_with_differences [key ].append ({
37
+ 'occurrences' : entry .occurrences ,
38
+ 'words' : {
39
+ 'original' : wordsid ,
40
+ 'translated' : wordsstr ,
41
+ },
42
+ })
43
+
44
+ return files_with_differences
45
+
46
+
47
+ pprint (main ())
You can’t perform that action at this time.
0 commit comments