Skip to content

Script to find format differences #1011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 19, 2021
Merged
Changes from 1 commit
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
Next Next commit
Script to find format differences
There is a lot of work to do here, but this is the initial of the idea.
  • Loading branch information
humitos committed Oct 8, 2020
commit b3bb7cbd5be86b07eb5240d359e2ca3599992eec
47 changes: 47 additions & 0 deletions scripts/format_differences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import collections
import os
import glob

from pprint import pprint

import polib # fades

PO_DIR = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..',
))


def main():
files_with_differences = collections.defaultdict(list)

for i, pofilename in enumerate(glob.glob(PO_DIR + '**/**/*.po')):
po = polib.pofile(pofilename)
if po.percent_translated() < 85:
continue

for entry in po:
words = []
wordsid = wordsstr = list()

if '*' in entry.msgid or '``' in entry.msgid:
wordsid = [word for word in entry.msgid.split() if '*' in word or '``' in word]

if '*' in entry.msgstr or '``' in entry.msgstr:
wordsstr = [word for word in entry.msgstr.split() if '*' in word or '``' in word]

if len(wordsid) != len(wordsstr):
key = pofilename.replace(PO_DIR, '')
files_with_differences[key].append({
'occurrences': entry.occurrences,
'words': {
'original': wordsid,
'translated': wordsstr,
},
})

return files_with_differences


pprint(main())