diff --git a/src/middlewared/middlewared/i18n.py b/src/middlewared/middlewared/i18n.py deleted file mode 100644 index e247ad250f10a..0000000000000 --- a/src/middlewared/middlewared/i18n.py +++ /dev/null @@ -1,32 +0,0 @@ -from gettext import NullTranslations, GNUTranslations -import logging -import pkg_resources - -logger = logging.getLogger(__name__) - -translations = NullTranslations() - - -def set_language(language): - global translations - - try: - with open(pkg_resources.resource_filename("middlewared", f"locale/{language}/LC_MESSAGES/middlewared.mo"), "rb") as f: - translations = GNUTranslations(f) - - return True - except Exception as e: - if language != "en": - logger.warning("Failed to set language %r: %r", language, e) - - translations = NullTranslations() - - return False - - -def _(message): - return translations.gettext(message) - - -def __(singular, plural, n): - return translations.ngettext(singular, plural, n) diff --git a/src/middlewared/middlewared/plugins/system/__init__.py b/src/middlewared/middlewared/plugins/system/__init__.py index a3b0bf1aafe78..525f43f67b200 100644 --- a/src/middlewared/middlewared/plugins/system/__init__.py +++ b/src/middlewared/middlewared/plugins/system/__init__.py @@ -40,5 +40,4 @@ async def setup(middleware): settings = await middleware.call('system.general.config') middleware.logger.debug('Setting timezone to %r', settings['timezone']) await middleware.call('core.environ_update', {'TZ': settings['timezone']}) - await middleware.call('system.general.set_language') await middleware.call('sysctl.set_zvol_volmode', 2) diff --git a/src/middlewared/middlewared/plugins/system_general/language.py b/src/middlewared/middlewared/plugins/system_general/language.py index aafab5281a5f9..daa97eb3822f5 100644 --- a/src/middlewared/middlewared/plugins/system_general/language.py +++ b/src/middlewared/middlewared/plugins/system_general/language.py @@ -1,6 +1,5 @@ -from middlewared.i18n import set_language from middlewared.schema import accepts, Dict, returns -from middlewared.service import private, Service +from middlewared.service import Service LANGUAGES = dict([ @@ -109,8 +108,3 @@ async def language_choices(self): Returns language choices. """ return LANGUAGES - - @private - def set_language(self): - language = self.middleware.call_sync('system.general.config')['language'] - set_language(language) diff --git a/src/middlewared/middlewared/plugins/system_general/update.py b/src/middlewared/middlewared/plugins/system_general/update.py index e9091d3bdc274..be1f013d2bafd 100644 --- a/src/middlewared/middlewared/plugins/system_general/update.py +++ b/src/middlewared/middlewared/plugins/system_general/update.py @@ -277,9 +277,6 @@ async def do_update(self, data): await self.middleware.call('service.reload', 'timeservices') await self.middleware.call('service.restart', 'cron') - if config['language'] != new_config['language']: - await self.middleware.call('system.general.set_language') - if config['ds_auth'] != new_config['ds_auth']: await self.middleware.call('etc.generate', 'pam_middleware')