Repository: learningequality/kolibri

Issue:
Uncaught SyntaxError: missing ) after argument list
### Observed behavior

Error on load in console, seems to be related to code in `hooks.py`:

```python
    def frontend_message_tag(self):
        if self.frontend_messages():
            return [
                '<script>{kolibri_name}.registerLanguageAssets("{bundle}", "{lang_code}", JSON.parse("{messages}"));</script>'.format(
                    kolibri_name="kolibriCoreAppGlobal",
                    bundle=self.unique_id,
                    lang_code=get_language(),
                    messages=json.dumps(
                        self.frontend_messages(),
                        separators=(",", ":"),
                        ensure_ascii=False,
                    )
                    .replace("'", "\\'")
                    .replace('"', '\\"'),
                )
            ]
        else:
            return []
```

Might also be preventing language assets from being loaded?

### Expected behavior

No error

### User-facing consequences

No translations on device page

### Errors and logs

```
Uncaught SyntaxError: missing ) after argument list
```

### Steps to reproduce

load device page

### Context

0.13.0 (develop)



Discussion:

Resolving patch:
diff --git a/kolibri/core/webpack/hooks.py b/kolibri/core/webpack/hooks.py
--- a/kolibri/core/webpack/hooks.py
+++ b/kolibri/core/webpack/hooks.py
@@ -262,17 +262,20 @@ def js_and_css_tags(self):
     def frontend_message_tag(self):
         if self.frontend_messages():
             return [
-                '<script>{kolibri_name}.registerLanguageAssets("{bundle}", "{lang_code}", JSON.parse("{messages}"));</script>'.format(
+                """
+                <script>
+                    {kolibri_name}.registerLanguageAssets('{bundle}', '{lang_code}', JSON.parse({messages}));
+                </script>""".format(
                     kolibri_name="kolibriCoreAppGlobal",
                     bundle=self.unique_id,
                     lang_code=get_language(),
                     messages=json.dumps(
-                        self.frontend_messages(),
-                        separators=(",", ":"),
-                        ensure_ascii=False,
-                    )
-                    .replace("'", "\\'")
-                    .replace('"', '\\"'),
+                        json.dumps(
+                            self.frontend_messages(),
+                            separators=(",", ":"),
+                            ensure_ascii=False,
+                        )
+                    ),
                 )
             ]
         else:
@@ -283,17 +286,17 @@ def plugin_data_tag(self):
             return [
                 """
                 <script>
-                    window["{name}"] = window["{name}"] || {{}};
-                    window["{name}"]["{bundle}"] = JSON.parse('{plugin_data}');
+                    window['{name}'] = window['{name}'] || {{}};
+                    window['{name}']['{bundle}'] = JSON.parse({plugin_data});
                 </script>
                 """.format(
                     name="kolibriPluginDataGlobal",
                     bundle=self.unique_id,
                     plugin_data=json.dumps(
-                        self.plugin_data, separators=(",", ":"), ensure_ascii=False
-                    )
-                    .replace("'", "\\'")
-                    .replace('"', '\\"'),
+                        json.dumps(
+                            self.plugin_data, separators=(",", ":"), ensure_ascii=False
+                        )
+                    ),
                 )
             ]
         else:


Test patch: