summaryrefslogtreecommitdiff
path: root/www/lang/checklang.py
blob: ea910cadff91de5fc6a8cd4bbcad5a31bab5e752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import json
import os

globGood=0
globBad=0

def compare (fname):
  global globGood, globBad
  with open (i) as json_data:
      newKeys = json.load(json_data)
      json_data.close()
  diffOrig = set(origKeys.keys()) - set(newKeys.keys())
  diffNew = set(newKeys.keys()) - set(origKeys.keys())
  if len(diffOrig)==0 and len (diffNew)==0:
    status = "GOOD"
    globGood+=1
  else:
    status = "ERROR"
    globBad+=1
  print "\n-------Checking:%s:%s---------" % (fname,status)
  print "master keys:%d, %s keys:%d" % (len(origKeys), i, len(newKeys))
  if len(diffOrig) > 0:
    print "Keys not present in :%s" %fname
    for x in diffOrig:
      print '-->',x
  if len(diffNew) > 0:
    print "Extra keys present in :%s" %fname
    for x in diffNew:
      print '-->',x
  


with open ('locale-en.json') as json_data:
  origKeys=json.load(json_data)
  json_data.close()

print "total keys in master language: ", len(origKeys)

for i in os.listdir(os.getcwd()):
  if i.endswith("-en.json") or not i.endswith(".json"):
    continue
  else:
    compare(i)
print "================================================="
print "Good files:%d, Bad files:%d, Total files:%d" % (globGood, globBad, globGood+globBad)
print "=================================================\n"