DEFAULT_LANG = 'en'
class _translations():
def __init__(self, path, section):
try:
# credits to nrgaway.
language = DEFAULT_LANG
language = locale.getdefaultlocale()[0].split('_')[0]
if language:
language = language
self.translations = path
stream = file(self.translations, 'r')
data = yaml.load(stream)
if data:
self.section = data[section]
self.language = self.section.get(language, DEFAULT_LANG)
except (IOError):
# TODO: add code here.
pass
except (yaml.scanner.ScannerError, yaml.parser.ParserError):
pass
def gettext(self, key):
return self.language.get(key, None)
Edit : I hope it is readable as I don’t know how to post otherwise here on the forum. Please do not hesitate to let me know if you need me to upload the file somewhere.
Edit 2 : @Patrick : thank you for editing my post. Now I know how to post
So it looks like you have an older version. You can wait fot Whonix 14, or try to replace the code in translations.py in the temptates (whonix-gw and whonix-ws) with
#!/usr/bin/python
import sys
import locale, yaml
DEFAULT_LANG = 'en'
class _translations():
def yaml_get(self):
with open(self.path) as stream:
data = yaml.safe_load(stream)
self.xxx = data[self.section]
self.result = self.xxx.get(self.language, DEFAULT_LANG)
def gettext(self, key):
if self.result == None:
self.yaml_get()
try:
text = self.result.get(key, None)
except:
print('ERROR: No translation for language "{}", key "{}".'.format(self.language, key))
self.language = DEFAULT_LANG
self.yaml_get()
text = self.result.get(key, None)
return(text)
def __init__(self, path, section):
# credits to nrgaway.
self.path = path
self.section = section
self.language = DEFAULT_LANG
self.result = None
try:
if locale.getdefaultlocale()[0] != None:
self.language = locale.getdefaultlocale()[0].split('_')[0]
except:
self.language = DEFAULT_LANG
print('ERROR: locale.getdefaultlocale failed. Using "{}" as default'.format(self.language))
Can you please report if it fixes the problem, or not.
.
@troubadour : I edited the file as requested in your answer and no error message appears anymore on the whonix-gw. Unfortunately the message still apears on whonix-ws. Is that possible ?
By the way, should I upgrade my system to the latest version of Whonix ? If yes, is it possible to do that without having to reinstall everything ? I mean, is it or will it be possible to upgrade sooner or later ?
Thank you for your answer + support & best rerards.
No, it should work in both. Perhaps you should double check the script in whonix-ws. Are you running Whonix under VirtualBox, KVM or Qubes?
For a relatively easy upgrade, it would be better to wait until Whonix 14 is officially released. If you feel brave, you can upgrade manually, following these instructions.