diff --git a/pkg/shell/index.html b/pkg/shell/index.html index 644a32a52723..895d7e5e0703 100644 --- a/pkg/shell/index.html +++ b/pkg/shell/index.html @@ -7,7 +7,7 @@ - + diff --git a/src/cockpit/packages.py b/src/cockpit/packages.py index 13fbe3e83967..3377ded69e0a 100644 --- a/src/cockpit/packages.py +++ b/src/cockpit/packages.py @@ -516,26 +516,27 @@ def reload_hint(self): self.reload() self.saw_first_reload_hint = True - def load_manifests_js(self, headers: JsonObject) -> Document: + def load_manifests_js(self, headers: JsonObject, *, i18n: bool) -> Document: logger.debug('Serving /manifests.js') chunks: List[bytes] = [] # Send the translations required for the manifest files, from each package - locales = parse_accept_language(get_str(headers, 'Accept-Language', '')) - for name, package in self.packages.items(): - if name in ['static', 'base1']: - continue + if i18n: + locales = parse_accept_language(get_str(headers, 'Accept-Language', '')) + for name, package in self.packages.items(): + if name in ['static', 'base1']: + continue - # find_translation will always find at least 'en' - translation = package.load_translation('po.manifest.js', locales) - with translation.data: - if translation.content_encoding == 'gzip': - data = gzip.decompress(translation.data.read()) - else: - data = translation.data.read() + # find_translation will always find at least 'en' + translation = package.load_translation('po.manifest.js', locales) + with translation.data: + if translation.content_encoding == 'gzip': + data = gzip.decompress(translation.data.read()) + else: + data = translation.data.read() - chunks.append(data) + chunks.append(data) chunks.append(b""" (function (root, data) { @@ -573,7 +574,9 @@ def load_path(self, path: str, headers: JsonObject) -> Document: if packagename is not None: return self.packages[packagename].load_path(filename, headers) elif filename == 'manifests.js': - return self.load_manifests_js(headers) + return self.load_manifests_js(headers, i18n=False) + elif filename == 'manifests-i18n.js': + return self.load_manifests_js(headers, i18n=True) elif filename == 'manifests.json': return self.load_manifests_json() else: diff --git a/test/pytest/test_packages.py b/test/pytest/test_packages.py index eaa8b6827dfb..e3aed57af9aa 100644 --- a/test/pytest/test_packages.py +++ b/test/pytest/test_packages.py @@ -233,7 +233,7 @@ def test_translation(pkgdir): assert document.data.read() == b'' # make sure the manifest translations get sent along with manifests.js - document = packages.load_path('/manifests.js', {'Accept-Language': 'de'}) + document = packages.load_path('/manifests-i18n.js', {'Accept-Language': 'de'}) contents = document.data.read() assert b'eins\n' in contents assert b'zwo\n' in contents