prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Hardcoded language ISO in instance info
  This line of code 
  
  https://github.com/bookwyrm-social/bookwyrm/blob/290b74039297349693f4f139fa58659a19d1e1ac/bookwyrm/views/wellknown.py#L113
  
  needs to be changed that the actual language of the instance is shown. My instance is set to German but it tells the world that it is in English.
  
  The problem I have here (and why I just not solved it right now) is that the language is represented by a ISO 639-1 two-letter code and I do not see that we have it here. The question is: Do we need 4 letter codes in `.env`/`settings.py`or can we somehow derive from this setting and get the two letter code? 
  
  Anyhow, I am too confused to do it atm.
  
  </issue>
  <code>
  [start of bookwyrm/views/wellknown.py]
  1 """ responds to various requests to /.well-know """
  2 
  3 from dateutil.relativedelta import relativedelta
  4 from django.http import HttpResponseNotFound
  5 from django.http import JsonResponse
  6 from django.shortcuts import get_object_or_404
  7 from django.template.response import TemplateResponse
  8 from django.utils import timezone
  9 from django.views.decorators.http import require_GET
  10 
  11 from bookwyrm import models
  12 from bookwyrm.settings import DOMAIN, VERSION
  13 
  14 
  15 @require_GET
  16 def webfinger(request):
  17     """allow other servers to ask about a user"""
  18     resource = request.GET.get("resource")
  19     if not resource or not resource.startswith("acct:"):
  20         return HttpResponseNotFound()
  21 
  22     username = resource.replace("acct:", "")
  23     user = get_object_or_404(models.User, username__iexact=username)
  24 
  25     return JsonResponse(
  26         {
  27             "subject": f"acct:{user.username}",
  28             "links": [
  29                 {
  30                     "rel": "self",
  31                     "type": "application/activity+json",
  32                     "href": user.remote_id,
  33                 },
  34                 {
  35                     "rel": "http://ostatus.org/schema/1.0/subscribe",
  36                     "template": f"https://{DOMAIN}/ostatus_subscribe?acct={{uri}}",
  37                 },
  38             ],
  39         }
  40     )
  41 
  42 
  43 @require_GET
  44 def nodeinfo_pointer(_):
  45     """direct servers to nodeinfo"""
  46     return JsonResponse(
  47         {
  48             "links": [
  49                 {
  50                     "rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
  51                     "href": f"https://{DOMAIN}/nodeinfo/2.0",
  52                 }
  53             ]
  54         }
  55     )
  56 
  57 
  58 @require_GET
  59 def nodeinfo(_):
  60     """basic info about the server"""
  61     status_count = models.Status.objects.filter(user__local=True, deleted=False).count()
  62     user_count = models.User.objects.filter(is_active=True, local=True).count()
  63 
  64     month_ago = timezone.now() - relativedelta(months=1)
  65     last_month_count = models.User.objects.filter(
  66         is_active=True, local=True, last_active_date__gt=month_ago
  67     ).count()
  68 
  69     six_months_ago = timezone.now() - relativedelta(months=6)
  70     six_month_count = models.User.objects.filter(
  71         is_active=True, local=True, last_active_date__gt=six_months_ago
  72     ).count()
  73 
  74     site = models.SiteSettings.get()
  75     return JsonResponse(
  76         {
  77             "version": "2.0",
  78             "software": {"name": "bookwyrm", "version": VERSION},
  79             "protocols": ["activitypub"],
  80             "usage": {
  81                 "users": {
  82                     "total": user_count,
  83                     "activeMonth": last_month_count,
  84                     "activeHalfyear": six_month_count,
  85                 },
  86                 "localPosts": status_count,
  87             },
  88             "openRegistrations": site.allow_registration,
  89         }
  90     )
  91 
  92 
  93 @require_GET
  94 def instance_info(_):
  95     """let's talk about your cool unique instance"""
  96     user_count = models.User.objects.filter(is_active=True, local=True).count()
  97     status_count = models.Status.objects.filter(user__local=True, deleted=False).count()
  98 
  99     site = models.SiteSettings.get()
  100     logo = site.logo_url
  101     return JsonResponse(
  102         {
  103             "uri": DOMAIN,
  104             "title": site.name,
  105             "short_description": site.instance_short_description,
  106             "description": site.instance_description,
  107             "version": VERSION,
  108             "stats": {
  109                 "user_count": user_count,
  110                 "status_count": status_count,
  111             },
  112             "thumbnail": logo,
  113             "languages": ["en"],
  114             "registrations": site.allow_registration,
  115             "approval_required": not site.allow_registration
  116             and site.allow_invite_requests,
  117             "email": site.admin_email,
  118         }
  119     )
  120 
  121 
  122 @require_GET
  123 def peers(_):
  124     """list of federated servers this instance connects with"""
  125     names = models.FederatedServer.objects.filter(status="federated").values_list(
  126         "server_name", flat=True
  127     )
  128     return JsonResponse(list(names), safe=False)
  129 
  130 
  131 @require_GET
  132 def host_meta(request):
  133     """meta of the host"""
  134     return TemplateResponse(request, "host_meta.xml", {"DOMAIN": DOMAIN})
  135 
  136 
  137 @require_GET
  138 def opensearch(request):
  139     """Open Search xml spec"""
  140     site = models.SiteSettings.get()
  141     image = site.favicon_url
  142     return TemplateResponse(
  143         request, "opensearch.xml", {"image": image, "DOMAIN": DOMAIN}
  144     )
  145
  [end of bookwyrm/views/wellknown.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/bookwyrm/views/wellknown.py b/bookwyrm/views/wellknown.py
  --- a/bookwyrm/views/wellknown.py
  +++ b/bookwyrm/views/wellknown.py
  @@ -9,7 +9,7 @@
   from django.views.decorators.http import require_GET
   
   from bookwyrm import models
  -from bookwyrm.settings import DOMAIN, VERSION
  +from bookwyrm.settings import DOMAIN, VERSION, LANGUAGE_CODE
   
   
   @require_GET
  @@ -110,7 +110,7 @@
                   "status_count": status_count,
               },
               "thumbnail": logo,
  -            "languages": ["en"],
  +            "languages": [LANGUAGE_CODE[:2]],
               "registrations": site.allow_registration,
               "approval_required": not site.allow_registration
               and site.allow_invite_requests,
  
verification_info: {"golden_diff": "diff --git a/bookwyrm/views/wellknown.py b/bookwyrm/views/wellknown.py\n--- a/bookwyrm/views/wellknown.py\n+++ b/bookwyrm/views/wellknown.py\n@@ -9,7 +9,7 @@\n from django.views.decorators.http import require_GET\n \n from bookwyrm import models\n-from bookwyrm.settings import DOMAIN, VERSION\n+from bookwyrm.settings import DOMAIN, VERSION, LANGUAGE_CODE\n \n \n @require_GET\n@@ -110,7 +110,7 @@\n                 \"status_count\": status_count,\n             },\n             \"thumbnail\": logo,\n-            \"languages\": [\"en\"],\n+            \"languages\": [LANGUAGE_CODE[:2]],\n             \"registrations\": site.allow_registration,\n             \"approval_required\": not site.allow_registration\n             and site.allow_invite_requests,\n", "issue": "Hardcoded language ISO in instance info\nThis line of code \r\n\r\nhttps://github.com/bookwyrm-social/bookwyrm/blob/290b74039297349693f4f139fa58659a19d1e1ac/bookwyrm/views/wellknown.py#L113\r\n\r\nneeds to be changed that the actual language of the instance is shown. My instance is set to German but it tells the world that it is in English.\r\n\r\nThe problem I have here (and why I just not solved it right now) is that the language is represented by a ISO 639-1 two-letter code and I do not see that we have it here. The question is: Do we need 4 letter codes in `.env`/`settings.py`or can we somehow derive from this setting and get the two letter code? \r\n\r\nAnyhow, I am too confused to do it atm.\n", "before_files": [{"content": "\"\"\" responds to various requests to /.well-know \"\"\"\n\nfrom dateutil.relativedelta import relativedelta\nfrom django.http import HttpResponseNotFound\nfrom django.http import JsonResponse\nfrom django.shortcuts import get_object_or_404\nfrom django.template.response import TemplateResponse\nfrom django.utils import timezone\nfrom django.views.decorators.http import require_GET\n\nfrom bookwyrm import models\nfrom bookwyrm.settings import DOMAIN, VERSION\n\n\n@require_GET\ndef webfinger(request):\n    \"\"\"allow other servers to ask about a user\"\"\"\n    resource = request.GET.get(\"resource\")\n    if not resource or not resource.startswith(\"acct:\"):\n        return HttpResponseNotFound()\n\n    username = resource.replace(\"acct:\", \"\")\n    user = get_object_or_404(models.User, username__iexact=username)\n\n    return JsonResponse(\n        {\n            \"subject\": f\"acct:{user.username}\",\n            \"links\": [\n                {\n                    \"rel\": \"self\",\n                    \"type\": \"application/activity+json\",\n                    \"href\": user.remote_id,\n                },\n                {\n                    \"rel\": \"http://ostatus.org/schema/1.0/subscribe\",\n                    \"template\": f\"https://{DOMAIN}/ostatus_subscribe?acct={{uri}}\",\n                },\n            ],\n        }\n    )\n\n\n@require_GET\ndef nodeinfo_pointer(_):\n    \"\"\"direct servers to nodeinfo\"\"\"\n    return JsonResponse(\n        {\n            \"links\": [\n                {\n                    \"rel\": \"http://nodeinfo.diaspora.software/ns/schema/2.0\",\n                    \"href\": f\"https://{DOMAIN}/nodeinfo/2.0\",\n                }\n            ]\n        }\n    )\n\n\n@require_GET\ndef nodeinfo(_):\n    \"\"\"basic info about the server\"\"\"\n    status_count = models.Status.objects.filter(user__local=True, deleted=False).count()\n    user_count = models.User.objects.filter(is_active=True, local=True).count()\n\n    month_ago = timezone.now() - relativedelta(months=1)\n    last_month_count = models.User.objects.filter(\n        is_active=True, local=True, last_active_date__gt=month_ago\n    ).count()\n\n    six_months_ago = timezone.now() - relativedelta(months=6)\n    six_month_count = models.User.objects.filter(\n        is_active=True, local=True, last_active_date__gt=six_months_ago\n    ).count()\n\n    site = models.SiteSettings.get()\n    return JsonResponse(\n        {\n            \"version\": \"2.0\",\n            \"software\": {\"name\": \"bookwyrm\", \"version\": VERSION},\n            \"protocols\": [\"activitypub\"],\n            \"usage\": {\n                \"users\": {\n                    \"total\": user_count,\n                    \"activeMonth\": last_month_count,\n                    \"activeHalfyear\": six_month_count,\n                },\n                \"localPosts\": status_count,\n            },\n            \"openRegistrations\": site.allow_registration,\n        }\n    )\n\n\n@require_GET\ndef instance_info(_):\n    \"\"\"let's talk about your cool unique instance\"\"\"\n    user_count = models.User.objects.filter(is_active=True, local=True).count()\n    status_count = models.Status.objects.filter(user__local=True, deleted=False).count()\n\n    site = models.SiteSettings.get()\n    logo = site.logo_url\n    return JsonResponse(\n        {\n            \"uri\": DOMAIN,\n            \"title\": site.name,\n            \"short_description\": site.instance_short_description,\n            \"description\": site.instance_description,\n            \"version\": VERSION,\n            \"stats\": {\n                \"user_count\": user_count,\n                \"status_count\": status_count,\n            },\n            \"thumbnail\": logo,\n            \"languages\": [\"en\"],\n            \"registrations\": site.allow_registration,\n            \"approval_required\": not site.allow_registration\n            and site.allow_invite_requests,\n            \"email\": site.admin_email,\n        }\n    )\n\n\n@require_GET\ndef peers(_):\n    \"\"\"list of federated servers this instance connects with\"\"\"\n    names = models.FederatedServer.objects.filter(status=\"federated\").values_list(\n        \"server_name\", flat=True\n    )\n    return JsonResponse(list(names), safe=False)\n\n\n@require_GET\ndef host_meta(request):\n    \"\"\"meta of the host\"\"\"\n    return TemplateResponse(request, \"host_meta.xml\", {\"DOMAIN\": DOMAIN})\n\n\n@require_GET\ndef opensearch(request):\n    \"\"\"Open Search xml spec\"\"\"\n    site = models.SiteSettings.get()\n    image = site.favicon_url\n    return TemplateResponse(\n        request, \"opensearch.xml\", {\"image\": image, \"DOMAIN\": DOMAIN}\n    )\n", "path": "bookwyrm/views/wellknown.py"}]}