修复多语言的问题

This commit is contained in:
wangsong 2022-06-17 20:32:46 +08:00
parent 50e55a0ed9
commit 986fe2f1f2
2 changed files with 16 additions and 13 deletions

View File

@ -43,13 +43,13 @@ _STRINGS_ERROR = {
#update
ERROR_UPDATE_DEFAULT_FAILED: _("Check for update exceptions,please check your network connection and retry."),
ERROR_UPDATE_SOURCE_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NETWORK_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NOT_GROUPS_CONFIG: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_UPDATE_KEY_SIGNATURES: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_READ_IMPORTANTLIST_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_SOFTWARE_INDEX_RROKEN: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NOT_INIT_PACKAGESINFIO: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_UPDATE_SOURCE_FAILED: _("Check for update exceptions,please check your network connection and retry."),
ERROR_NETWORK_FAILED: _("Check for update exceptions,please check your network connection and retry."),
ERROR_NOT_GROUPS_CONFIG: _("Check for update exceptions,please check your network connection and retry."),
ERROR_UPDATE_KEY_SIGNATURES: _("Check for update exceptions,please check your network connection and retry."),
ERROR_READ_IMPORTANTLIST_FAILED: _("Check for update exceptions,please check your network connection and retry."),
ERROR_SOFTWARE_INDEX_RROKEN: _("Check for update exceptions,please check your network connection and retry."),
ERROR_NOT_INIT_PACKAGESINFIO: _("Check for update exceptions,please check your network connection and retry."),
#install
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),

View File

@ -8,13 +8,15 @@ import apt_pkg
from gettext import gettext as _
from .backend import InstallBackend
from .Core.loop import mainloop
import SystemUpdater.Core.enums as enums
from .Core.errors import *
from .Core.enums import *
# from .Core.enums import *
from .Core.utils import humanize_size
from SystemUpdater.Core.utils import get_proc_from_dbus_name,PolicyKit_Authority
import locale
from xml.etree import ElementTree
from .Core.MyCache import MyCache
from importlib import reload
UPDATER_DBUS_INTERFACE = 'com.kylin.systemupgrade.interface'
UPDATER_DBUS_PATH = '/com/kylin/systemupgrade'
@ -60,15 +62,15 @@ class UpdateManagerDbusController(dbus.service.Object):
def _update_important_reply(self,retval):
if bool(retval) == False:
self.UpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),\
get_error_description_from_enum(ERROR_UPDATE_SOURCE_FAILED))
self.UpdateDetectFinished(False,[''],enums.get_error_string_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED),\
enums.get_error_description_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED))
else:
self.parent.start_update_backend()
def _update_important_error(self,retval):
logging.error(str(retval))
self.UpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),\
get_error_description_from_enum(ERROR_UPDATE_SOURCE_FAILED))
self.UpdateDetectFinished(False,[''],enums.get_error_string_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED),\
enums.get_error_description_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED))
#更新important.list的本次升级的列表
def on_update_important_list(self):
@ -116,7 +118,7 @@ class UpdateManagerDbusController(dbus.service.Object):
retval = interface.CheckConnectivity(timeout=0.5)
#1 表示没有网卡可以使用
if retval == 1:
raise UpdateBaseError(ERROR_NETWORK_FAILED)
raise UpdateBaseError(enums.ERROR_NETWORK_FAILED)
except Exception:
pass
@ -224,6 +226,7 @@ class UpdateManagerDbusController(dbus.service.Object):
if lang != os.environ["LANGUAGE"]:
logging.warning("The system language is switched %s to %s",os.environ["LANGUAGE"],lang)
os.environ["LANGUAGE"] = lang
reload(enums)
return self.parent.now_working
except Exception as e: