Poodletooth-iLand/otp/otpbase/OTPLocalizer.py

36 lines
1.3 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
import string
import types
2015-03-13 10:02:14 -05:00
2015-03-03 16:10:12 -06:00
try:
2015-03-13 10:02:14 -05:00
language = settings['language']
2015-03-03 16:10:12 -06:00
except:
2015-03-13 10:02:14 -05:00
language = 'English'
2015-03-03 16:10:12 -06:00
print 'OTPLocalizer: Running in language: %s' % language
from otp.otpbase.OTPLocalizerEnglish import *
2015-03-13 10:02:14 -05:00
if language != 'English':
2015-03-03 16:10:12 -06:00
l = {}
g = {}
2015-03-13 12:14:04 -05:00
module = 'otp.otpbase.OTPLocalizer' + language
2015-03-03 16:10:12 -06:00
englishModule = __import__('otp.otpbase.OTPLocalizerEnglish', g, l)
2015-03-13 10:02:14 -05:00
foreignModule = __import__(module, g, l)
2015-03-03 16:10:12 -06:00
for key, val in englishModule.__dict__.items():
if key not in foreignModule.__dict__:
2015-03-13 10:02:14 -05:00
print 'WARNING: Foreign module: %s missing key: %s' % (module, key)
2015-03-03 16:10:12 -06:00
locals()[key] = val
elif isinstance(val, types.DictType):
fval = foreignModule.__dict__.get(key)
for dkey, dval in val.items():
if dkey not in fval:
2015-03-13 10:02:14 -05:00
print 'WARNING: Foreign module: %s missing key: %s.%s' % (module, key, dkey)
2015-03-03 16:10:12 -06:00
fval[dkey] = dval
for dkey in fval.keys():
if dkey not in val:
2015-03-13 10:02:14 -05:00
print 'WARNING: Foreign module: %s extra key: %s.%s' % (module, key, dkey)
2015-03-03 16:10:12 -06:00
for key in foreignModule.__dict__.keys():
if key not in englishModule.__dict__:
2015-03-13 10:02:14 -05:00
print 'WARNING: Foreign module: %s extra key: %s' % (module, key)