2019-11-02 18:49:34 -05:00
|
|
|
from panda3d.core import *
|
2022-01-18 23:40:24 -06:00
|
|
|
|
|
|
|
language = ConfigVariableString('language', 'english').value
|
|
|
|
checkLanguage = ConfigVariableBool('check-language', 0).value
|
2019-11-02 17:27:54 -05:00
|
|
|
|
|
|
|
def getLanguage():
|
|
|
|
return language
|
|
|
|
|
|
|
|
|
2019-12-30 00:00:16 -06:00
|
|
|
print('OTPLocalizer: Running in language: %s' % language)
|
2019-11-02 17:27:54 -05:00
|
|
|
if language == 'english':
|
2019-12-30 00:59:01 -06:00
|
|
|
_languageModule = 'otp.otpbase.OTPLocalizer' + language.capitalize()
|
2019-11-02 17:27:54 -05:00
|
|
|
else:
|
|
|
|
checkLanguage = 1
|
|
|
|
_languageModule = 'otp.otpbase.OTPLocalizer_' + language
|
2019-12-30 00:00:16 -06:00
|
|
|
print('from ' + _languageModule + ' import *')
|
2019-11-02 17:27:54 -05:00
|
|
|
from otp.otpbase.OTPLocalizerEnglish import *
|
|
|
|
if checkLanguage:
|
|
|
|
l = {}
|
|
|
|
g = {}
|
|
|
|
englishModule = __import__('otp.otpbase.OTPLocalizerEnglish', g, l)
|
|
|
|
foreignModule = __import__(_languageModule, g, l)
|
2019-12-30 00:00:16 -06:00
|
|
|
for key, val in list(englishModule.__dict__.items()):
|
|
|
|
if key not in foreignModule.__dict__:
|
|
|
|
print('WARNING: Foreign module: %s missing key: %s' % (_languageModule, key))
|
2019-11-02 17:27:54 -05:00
|
|
|
locals()[key] = val
|
2019-12-30 00:00:16 -06:00
|
|
|
elif isinstance(val, dict):
|
2019-11-02 17:27:54 -05:00
|
|
|
fval = foreignModule.__dict__.get(key)
|
2019-12-30 00:00:16 -06:00
|
|
|
for dkey, dval in list(val.items()):
|
|
|
|
if dkey not in fval:
|
|
|
|
print('WARNING: Foreign module: %s missing key: %s.%s' % (_languageModule, key, dkey))
|
2019-11-02 17:27:54 -05:00
|
|
|
fval[dkey] = dval
|
|
|
|
|
2019-12-30 00:00:16 -06:00
|
|
|
for dkey in list(fval.keys()):
|
|
|
|
if dkey not in val:
|
|
|
|
print('WARNING: Foreign module: %s extra key: %s.%s' % (_languageModule, key, dkey))
|
2019-11-02 17:27:54 -05:00
|
|
|
|
2019-12-30 00:00:16 -06:00
|
|
|
for key in list(foreignModule.__dict__.keys()):
|
|
|
|
if key not in englishModule.__dict__:
|
|
|
|
print('WARNING: Foreign module: %s extra key: %s' % (_languageModule, key))
|