apt: request translation when executing the mirror check

By setting the LANG variable and passing clean_locale=False, the apt-get
command will be translated if the locale definition exists on the
system.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2023-02-01 23:16:27 +01:00
parent f284d25757
commit 7bb5742685
2 changed files with 5 additions and 1 deletions

View File

@ -173,7 +173,10 @@ class AptConfigurer:
apt_cmd.append(
f"-o{target}::DefaultEnabled=false")
proc = await astart_command(apt_cmd, stderr=subprocess.STDOUT)
env = os.environ.copy()
env["LANG"] = self.app.base_model.locale.selected_language
proc = await astart_command(apt_cmd, stderr=subprocess.STDOUT,
clean_locale=False, env=env)
async def _reader():
while not proc.stdout.at_eof():

View File

@ -60,6 +60,7 @@ class TestAptConfigurer(SubiTestCase):
self.model = Mock()
self.model.mirror = MirrorModel()
self.model.proxy = ProxyModel()
self.model.locale.selected_language = "en_US.UTF-8"
self.app = make_app(self.model)
self.configurer = AptConfigurer(self.app, AsyncMock(), '')