diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2016-12-04 20:21:53 -0500 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2016-12-04 20:21:53 -0500 |
| commit | 39b80e16a03b7453cd8211f293176be0a58d9a37 (patch) | |
| tree | 5a7c450c11fef988cbffdf7ae56ade7f04e42948 /www | |
| parent | 353e1d5ecd686d64e1a6166116e7653cd0bc1295 (diff) | |
updated lang python script to a common one
Diffstat (limited to 'www')
| -rw-r--r-- | www/js/NewsCtrl.js | 1 | ||||
| -rw-r--r-- | www/js/app.js | 2 | ||||
| -rwxr-xr-x | www/lang/checklang.py | 50 | ||||
| -rwxr-xr-x | www/lang/checklang.py3 | 121 |
4 files changed, 30 insertions, 144 deletions
diff --git a/www/js/NewsCtrl.js b/www/js/NewsCtrl.js index f6709320..e1e030ec 100644 --- a/www/js/NewsCtrl.js +++ b/www/js/NewsCtrl.js @@ -94,6 +94,7 @@ angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$ro } } + window.open(item, '_blank', 'location=yes'); return false; }; diff --git a/www/js/app.js b/www/js/app.js index ad474df8..4de2426f 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1823,6 +1823,8 @@ angular.module('zmApp', [ //$httpProvider.defaults.withCredentials = true; $httpProvider.interceptors.push('timeoutHttpIntercept'); $ionicConfigProvider.navBar.alignTitle('center'); + //$ionicConfigProvider.backButton.text('').icon('ion-chevron-left'); + //$ionicConfigProvider.backButton.text('').icon('ion-chevron-left').previousTitleText(false); // use overflow-scroll=false in ion-content // removing it here doesn't allow you to enable it per view // so it messes up scrolldelegate zoom and possibly others diff --git a/www/lang/checklang.py b/www/lang/checklang.py index cf3291fe..3ae37fa5 100755 --- a/www/lang/checklang.py +++ b/www/lang/checklang.py @@ -1,8 +1,9 @@ #!/usr/bin/env python +from __future__ import absolute_import, division, print_function, unicode_literals +import sys import json import os import getopt -import sys globGood=0 globBad=0 @@ -12,13 +13,13 @@ globFile="" # prints usage def usage(): - print ( + print(( 'Usage: '+sys.argv[0]+'\n' ' -h|--help: this help\n' ' -f|file <fname>: only processes that file\n' ' -b|--beautify: beautifies the json file\n' ' -o|--overwrite: when used with -b/--beautify overwrites the file without adding a pretty- prefix. Use with caution\n' - ) + )) #beautifies a given file @@ -28,28 +29,31 @@ def beautify(fi,ki): prefix='' else: prefix='pretty-' - print "Beautifying %s, writing to %s" % (fi,prefix+fi) + print("Beautifying %s, writing to %s" % (fi,prefix+fi)) w = len (max(ki, key=len)) pretty=[] for k in sorted(ki): line = " \"%s\"%s:\"%s\"" %(k,' '*(w-len(k)+1),ki[k]) pretty.append(line) - pFh=open (prefix+fi,"w") - pFh.write("{\n") - pFh.write(',\n'.join(pretty).encode('utf-8')) - pFh.write("\n}\n") + pFh=open(prefix+fi,"w") + pFh.write('{\n') + if sys.version_info >=(3, 0): + pFh.write(",\n".join(pretty)) + else: + pFh.write(",\n".join(pretty).encode('UTF-8')) + pFh.write('\n}\n') pFh.close() #Compares keys in language file -def compare (fname): + +def compare(fname): beaut="no" global globGood, globBad,globOverwrite, globFile, globBeautify with open (i) as json_data: try: newKeys = json.load(json_data) - except ValueError as e: - print 'could not parse %s, skipping!' %fname - print 'Error was %s' % str(e) + except ValueError: + print('could not parse %s, skipping!' %fname) globBad+=1 return json_data.close() @@ -63,18 +67,18 @@ def compare (fname): else: status = "ERROR" globBad+=1 - print "\n-------Checking:%s:%s, beautify:%s---------" % (fname,status,beaut) - print "master keys:%d, %s keys:%d" % (len(origKeys), i, len(newKeys)) + print("\n-------Checking:%s:%s, beautify:%s---------" % (fname,status,beaut)) + print("master keys:%d, %s keys:%d" % (len(origKeys), i, len(newKeys))) if beaut=="YES": beautify(fname,newKeys) if len(diffOrig) > 0: - print "Keys not present in :%s" %fname + print("Keys not present in :%s" %fname) for x in diffOrig: - print '-->',x + print("-->",x) if len(diffNew) > 0: - print "Extra keys present in :%s" %fname + print("Extra keys present in :%s" %fname) for x in diffNew: - print '-->',x + print("-->",x) @@ -101,7 +105,7 @@ with open ('locale-en.json') as json_data: origKeys=json.load(json_data) json_data.close() -print "total keys in master language: ", len(origKeys) +print("total keys in master language: ", len(origKeys)) #iterate through all languages, using -en as the master for i in os.listdir(os.getcwd()): @@ -112,11 +116,11 @@ for i in os.listdir(os.getcwd()): if globFile == "" or globFile == i: compare(i) else: - print "skipping ",i, " as its not ",globFile + print("skipping ",i, " as its not ",globFile) -print "=================================================" -print "Good files:%d, Bad files:%d, Total files:%d" % (globGood, globBad, globGood+globBad) -print "=================================================\n" +print("=================================================") +print("Good files:%d, Bad files:%d, Total files:%d" % (globGood, globBad, globGood+globBad)) +print("=================================================\n") diff --git a/www/lang/checklang.py3 b/www/lang/checklang.py3 deleted file mode 100755 index 10963da2..00000000 --- a/www/lang/checklang.py3 +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python -import json -import os -import getopt -import sys - -globGood=0 -globBad=0 -globBeautify=0 -globOverwrite=0 -globFile="" - -# prints usage -def usage(): - print(( - 'Usage: '+sys.argv[0]+'\n' - ' -h|--help: this help\n' - ' -f|file <fname>: only processes that file\n' - ' -b|--beautify: beautifies the json file\n' - ' -o|--overwrite: when used with -b/--beautify overwrites the file without adding a pretty- prefix. Use with caution\n' - )) - - -#beautifies a given file -def beautify(fi,ki): - global globOverwrite - if globOverwrite: - prefix='' - else: - prefix='pretty-' - print("Beautifying %s, writing to %s" % (fi,prefix+fi)) - w = len (max(ki, key=len)) - pretty=[] - for k in sorted(ki): - line = " \"%s\"%s:\"%s\"" %(k,' '*(w-len(k)+1),ki[k]) - pretty.append(line) - pFh=open (prefix+fi,"w") - pFh.write("{\n") - pFh.write(',\n'.join(pretty).encode('utf-8')) - pFh.write("\n}\n") - pFh.close() - -#Compares keys in language file -def compare (fname): - beaut="no" - global globGood, globBad,globOverwrite, globFile, globBeautify - with open (i) as json_data: - try: - newKeys = json.load(json_data) - except ValueError: - print('could not parse %s, skipping!' %fname) - globBad+=1 - return - 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 - if globBeautify and globFile == fname or globFile == "": - beaut="YES" - else: - status = "ERROR" - globBad+=1 - print("\n-------Checking:%s:%s, beautify:%s---------" % (fname,status,beaut)) - print("master keys:%d, %s keys:%d" % (len(origKeys), i, len(newKeys))) - if beaut=="YES": - beautify(fname,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) - - - -#MAIN -try: - myopts,args=getopt.getopt(sys.argv[1:],"f:hob",["file=","help","overwrite","beautify"]) -except getopt.GetoptError as err: - print (err) - usage() - sys.exit(2) - -for o,a in myopts: - if o in ("-h","--help"): - usage() - sys.exit() - elif o in ("-b","--beautify"): - globBeautify=1 - elif o in ("-o","--overwrite"): - globOverwrite=1 - elif o in ("-f","--file"): - globFile=a - -with open ('locale-en.json') as json_data: - origKeys=json.load(json_data) - json_data.close() - -print("total keys in master language: ", len(origKeys)) - -#iterate through all languages, using -en as the master -for i in os.listdir(os.getcwd()): - if not i.endswith(".json") or not i.startswith("locale-"): - #print "skipping ",i," as we will only process locale-*.json" - continue - else: - if globFile == "" or globFile == i: - compare(i) - else: - print("skipping ",i, " as its not ",globFile) - -print("=================================================") -print("Good files:%d, Bad files:%d, Total files:%d" % (globGood, globBad, globGood+globBad)) -print("=================================================\n") - - - |
