We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Macro search results are mangled for non-en-US locales
See for example https://wiki.developer.mozilla.org/en-US/search?locale=*&kumascript_macros=WebExtAllExamples&topic=none

This lists all pages that call WebExtAllExamples, across all locales. One entry looks like:

<img width="893" alt="Screen Shot 2019-11-21 at 4 30 25 PM" src="https://user-images.githubusercontent.com/432915/69387936-3e5d4780-0c7c-11ea-9347-5916d638d12d.png">

This is the German translation of the https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples page.

But the first link, "**Beispiele für Erweiterungen**", has the en-US locale in the URL, like this: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - note the translated slug but the en-US locale. If I click it, I get "Create a new page", because that page doesn't exist.

After the short description, the entry is supposed to have "`${url} Score: 82.20941 translated from ${original}`, where `url` is the localized page, and `original` is the en-US version. But these are wrong too:

* `url`: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - nonexistent page with en-US locale but de slug
* `original`: https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Beispiele - the proper value for `url`

 I've seen some cases where the "`${url} Score: 82.20941 translated from ${original}` bit doesn't appear, and then there is no usable link to the actual page, and I have to guess what the locale is, to be able to fix the link.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kuma/search/fields.py`
Content:
```
1 from django.conf import settings
2 from rest_framework import serializers
3 
4 from kuma.core.urlresolvers import reverse
5 
6 
7 class SearchQueryField(serializers.ReadOnlyField):
8     """
9     Field that returns the search query of the current request.
10     """
11     def __init__(self, *args, **kwargs):
12         kwargs['source'] = '*'
13         super(SearchQueryField, self).__init__(*args, **kwargs)
14 
15     def to_representation(self, value):
16         request = self.context.get('request')
17         if request is None:
18             return ''
19         else:
20             return request.query_params.get('q', None)
21 
22 
23 class SiteURLField(serializers.ReadOnlyField):
24     """
25     A serializer field for creating URL for the given objects with the
26     given ``args``/``kwargs`` and a required ``locale`` attribute.
27     """
28     def __init__(self, url_name, args=None, kwargs=None):
29         self.url_name = url_name
30         self.args = args or []
31         self.kwargs = kwargs or []
32         super(SiteURLField, self).__init__(source='*')
33 
34     def to_representation(self, value):
35         if not value:
36             return None
37         args = [getattr(value, arg) for arg in self.args]
38         kwargs = {arg: getattr(value, arg) for arg in self.kwargs}
39         locale = getattr(value, 'locale', settings.LANGUAGE_CODE)
40         path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)
41         return '%s%s' % (settings.SITE_URL, path)
42
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kuma/search/fields.py b/kuma/search/fields.py
--- a/kuma/search/fields.py
+++ b/kuma/search/fields.py
@@ -37,5 +37,4 @@
         args = [getattr(value, arg) for arg in self.args]
         kwargs = {arg: getattr(value, arg) for arg in self.kwargs}
         locale = getattr(value, 'locale', settings.LANGUAGE_CODE)
-        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)
-        return '%s%s' % (settings.SITE_URL, path)
+        return reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)

{"golden_diff": "diff --git a/kuma/search/fields.py b/kuma/search/fields.py\n--- a/kuma/search/fields.py\n+++ b/kuma/search/fields.py\n@@ -37,5 +37,4 @@\n         args = [getattr(value, arg) for arg in self.args]\n         kwargs = {arg: getattr(value, arg) for arg in self.kwargs}\n         locale = getattr(value, 'locale', settings.LANGUAGE_CODE)\n-        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n-        return '%s%s' % (settings.SITE_URL, path)\n+        return reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n", "issue": "Macro search results are mangled for non-en-US locales\nSee for example https://wiki.developer.mozilla.org/en-US/search?locale=*&kumascript_macros=WebExtAllExamples&topic=none\r\n\r\nThis lists all pages that call WebExtAllExamples, across all locales. One entry looks like:\r\n\r\n<img width=\"893\" alt=\"Screen Shot 2019-11-21 at 4 30 25 PM\" src=\"https://user-images.githubusercontent.com/432915/69387936-3e5d4780-0c7c-11ea-9347-5916d638d12d.png\">\r\n\r\nThis is the German translation of the https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples page.\r\n\r\nBut the first link, \"**Beispiele f\u00fcr Erweiterungen**\", has the en-US locale in the URL, like this: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - note the translated slug but the en-US locale. If I click it, I get \"Create a new page\", because that page doesn't exist.\r\n\r\nAfter the short description, the entry is supposed to have \"`${url} Score: 82.20941 translated from ${original}`, where `url` is the localized page, and `original` is the en-US version. But these are wrong too:\r\n\r\n* `url`: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Beispiele - nonexistent page with en-US locale but de slug\r\n* `original`: https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Beispiele - the proper value for `url`\r\n\r\n I've seen some cases where the \"`${url} Score: 82.20941 translated from ${original}` bit doesn't appear, and then there is no usable link to the actual page, and I have to guess what the locale is, to be able to fix the link.\r\n\r\n\n", "before_files": [{"content": "from django.conf import settings\nfrom rest_framework import serializers\n\nfrom kuma.core.urlresolvers import reverse\n\n\nclass SearchQueryField(serializers.ReadOnlyField):\n    \"\"\"\n    Field that returns the search query of the current request.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        kwargs['source'] = '*'\n        super(SearchQueryField, self).__init__(*args, **kwargs)\n\n    def to_representation(self, value):\n        request = self.context.get('request')\n        if request is None:\n            return ''\n        else:\n            return request.query_params.get('q', None)\n\n\nclass SiteURLField(serializers.ReadOnlyField):\n    \"\"\"\n    A serializer field for creating URL for the given objects with the\n    given ``args``/``kwargs`` and a required ``locale`` attribute.\n    \"\"\"\n    def __init__(self, url_name, args=None, kwargs=None):\n        self.url_name = url_name\n        self.args = args or []\n        self.kwargs = kwargs or []\n        super(SiteURLField, self).__init__(source='*')\n\n    def to_representation(self, value):\n        if not value:\n            return None\n        args = [getattr(value, arg) for arg in self.args]\n        kwargs = {arg: getattr(value, arg) for arg in self.kwargs}\n        locale = getattr(value, 'locale', settings.LANGUAGE_CODE)\n        path = reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n        return '%s%s' % (settings.SITE_URL, path)\n", "path": "kuma/search/fields.py"}], "after_files": [{"content": "from django.conf import settings\nfrom rest_framework import serializers\n\nfrom kuma.core.urlresolvers import reverse\n\n\nclass SearchQueryField(serializers.ReadOnlyField):\n    \"\"\"\n    Field that returns the search query of the current request.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        kwargs['source'] = '*'\n        super(SearchQueryField, self).__init__(*args, **kwargs)\n\n    def to_representation(self, value):\n        request = self.context.get('request')\n        if request is None:\n            return ''\n        else:\n            return request.query_params.get('q', None)\n\n\nclass SiteURLField(serializers.ReadOnlyField):\n    \"\"\"\n    A serializer field for creating URL for the given objects with the\n    given ``args``/``kwargs`` and a required ``locale`` attribute.\n    \"\"\"\n    def __init__(self, url_name, args=None, kwargs=None):\n        self.url_name = url_name\n        self.args = args or []\n        self.kwargs = kwargs or []\n        super(SiteURLField, self).__init__(source='*')\n\n    def to_representation(self, value):\n        if not value:\n            return None\n        args = [getattr(value, arg) for arg in self.args]\n        kwargs = {arg: getattr(value, arg) for arg in self.kwargs}\n        locale = getattr(value, 'locale', settings.LANGUAGE_CODE)\n        return reverse(self.url_name, locale=locale, args=args, kwargs=kwargs)\n", "path": "kuma/search/fields.py"}]}