diff options
author | uau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-05-16 18:09:14 +0000 |
---|---|---|
committer | uau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-05-16 18:09:14 +0000 |
commit | 69fadf586e3b5844ef581bc449794d7c095bcfc8 (patch) | |
tree | 244c4dd12718e2ccb679685e09d48381eb67e642 /TOOLS | |
parent | 5f7d1c128c09bbd67920fc0fb3eeb85d1c05ff89 (diff) | |
download | mpv-69fadf586e3b5844ef581bc449794d7c095bcfc8.tar.bz2 mpv-69fadf586e3b5844ef581bc449794d7c095bcfc8.tar.xz |
Add tool to check MPlayer translation files for conflicting arguments
and extra/missing translation strings.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18523 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rwxr-xr-x | TOOLS/mphelp_check.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/TOOLS/mphelp_check.py b/TOOLS/mphelp_check.py new file mode 100755 index 0000000000..cc306e3de0 --- /dev/null +++ b/TOOLS/mphelp_check.py @@ -0,0 +1,66 @@ +#!/usr/bin/python + +# Tool to compare MPlayer translation files against a base file. Reports +# conflicting arguments, extra strings not present in the base file and +# (optionally) missing strings. + +# Written by Uoti Urpala + +import sys +import re + +def parse(filename): + r = {} + f = open(filename) + it = iter(f) + cur = '' + for line in it: + line = line.strip() + if not line.startswith('#define'): + while line and line[-1] == '\\': + line = it.next().strip() + continue + _, name, value = line.split(None, 2) + value = value.strip('"') + while line[-1] == '\\': + line = it.next().strip() + value += line.rstrip('\\').strip('"') + r[name] = value + f.close() + return r + +def compare(base, other, show_missing=False): + r = re.compile('%[^diouxXeEfFgGaAcsPn%]*[diouxXeEfFgGaAcsPn%]') + missing = [] + for key in base: + if key not in other: + missing.append(key) + continue + if re.findall(r, base[key]) != re.findall(r, other[key]): + print 'Mismatch: ', key + print base[key] + print other[key] + print + del other[key] + if other: + extra = other.keys() + extra.sort() + print 'Extra: ', ' '.join(extra) + if show_missing and missing: + missing.sort() + print 'Missing: ', ' '.join(missing) + +if len(sys.argv) < 3: + print 'Usage:\n'+sys.argv[0]+' [-missing] base_helpfile otherfile1 '\ + '[otherfile2 ...]' + sys.exit(1) +i = 1 +show_missing = False +if sys.argv[i] == '-missing': + show_missing = True + i = 2 +base = parse(sys.argv[i]) +for filename in sys.argv[i+1:]: + print '*****', filename + compare(base, parse(filename), show_missing) + print '\n\n\n' |