Always translate html files to avoid compatibility problems with brackets in url

This commit is contained in:
shortcutme 2019-04-15 22:16:47 +02:00
parent bf7597e1b2
commit 90fee9788d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -7,11 +7,19 @@ from Translate import translate
@PluginManager.registerTo("UiRequest")
class UiRequestPlugin(object):
def actionSiteMedia(self, path, **kwargs):
file_name = path.split("/")[-1]
file_name = path.split("/")[-1].lower()
if not file_name: # Path ends with /
file_name = "index.html"
extension = file_name.split(".")[-1]
if translate.lang != "en" and extension in ["js", "html"]:
if extension == "html": # Always replace translate variables in html files
should_translate = True
elif extension == "js" and translate.lang != "en":
should_translate = True
else:
should_translate = False
if should_translate:
path_parts = self.parsePath(path)
kwargs["header_length"] = False
file_generator = super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs)