We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add Brazilian Portugese to localization footer
https://hosted.weblate.org/projects/pypa/warehouse/#translations says that we're now at 100% translated for Brazilian Portugese. Therefore, let's insert the footer of available locales/translations per #6624, and add Brazilian Portugese.

@yeraydiazdiaz @nlhkabu can either of you do this? Thanks.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `warehouse/i18n/__init__.py`
Content:
```
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12 
13 from babel.core import Locale
14 from pyramid.i18n import TranslationStringFactory, default_locale_negotiator
15 from pyramid.threadlocal import get_current_request
16 
17 KNOWN_LOCALES = {"en": "English"}
18 
19 LOCALE_ATTR = "_LOCALE_"
20 
21 _translation_factory = TranslationStringFactory("messages")
22 
23 
24 class LazyString:
25     def __init__(self, fn, *args, **kwargs):
26         self.fn = fn
27         self.args = args
28         self.mapping = kwargs.get("mapping", {})
29         self.kwargs = kwargs
30 
31     def __json__(self, request):
32         return str(self)
33 
34     def __mod__(self, new_mapping):
35         mapping = self.mapping.copy()
36         mapping.update(new_mapping)
37         return LazyString(self.fn, *self.args, mapping=new_mapping, **self.kwargs)
38 
39     def __str__(self):
40         return self.fn(*self.args, **self.kwargs)
41 
42 
43 def _locale(request):
44     """
45     Computes a babel.core:Locale() object for this request.
46     """
47     return Locale.parse(request.locale_name, sep="_")
48 
49 
50 def _negotiate_locale(request):
51     locale_name = getattr(request, LOCALE_ATTR, None)
52     if locale_name is not None:
53         return locale_name
54 
55     locale_name = request.params.get(LOCALE_ATTR)
56     if locale_name is not None:
57         return locale_name
58 
59     locale_name = request.cookies.get(LOCALE_ATTR)
60     if locale_name is not None:
61         return locale_name
62 
63     if not request.accept_language:
64         return default_locale_negotiator(request)
65 
66     return request.accept_language.best_match(
67         tuple(KNOWN_LOCALES.keys()), default_match=default_locale_negotiator(request)
68     )
69 
70 
71 def localize(message, **kwargs):
72     def _localize(message, **kwargs):
73         request = get_current_request()
74         return request.localizer.translate(_translation_factory(message, **kwargs))
75 
76     return LazyString(_localize, message, **kwargs)
77 
78 
79 def includeme(config):
80     # Add the request attributes
81     config.add_request_method(_locale, name="locale", reify=True)
82 
83     # Register our translation directory.
84     config.add_translation_dirs("warehouse:locale/")
85 
86     config.set_locale_negotiator(_negotiate_locale)
87 
88     # Register our i18n/l10n filters for Jinja2
89     filters = config.get_settings().setdefault("jinja2.filters", {})
90     filters.setdefault("format_date", "warehouse.i18n.filters:format_date")
91     filters.setdefault("format_datetime", "warehouse.i18n.filters:format_datetime")
92     filters.setdefault(
93         "format_rfc822_datetime", "warehouse.i18n.filters:format_rfc822_datetime"
94     )
95     filters.setdefault("format_number", "warehouse.i18n.filters:format_number")
96 
97     jglobals = config.get_settings().setdefault("jinja2.globals", {})
98     jglobals.setdefault("KNOWN_LOCALES", "warehouse.i18n:KNOWN_LOCALES")
99
```
--- 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/warehouse/i18n/__init__.py b/warehouse/i18n/__init__.py
--- a/warehouse/i18n/__init__.py
+++ b/warehouse/i18n/__init__.py
@@ -14,7 +14,7 @@
 from pyramid.i18n import TranslationStringFactory, default_locale_negotiator
 from pyramid.threadlocal import get_current_request
 
-KNOWN_LOCALES = {"en": "English"}
+KNOWN_LOCALES = {"en": "English", "pt_BR": "Portuguese (Brazil)"}
 
 LOCALE_ATTR = "_LOCALE_"

{"golden_diff": "diff --git a/warehouse/i18n/__init__.py b/warehouse/i18n/__init__.py\n--- a/warehouse/i18n/__init__.py\n+++ b/warehouse/i18n/__init__.py\n@@ -14,7 +14,7 @@\n from pyramid.i18n import TranslationStringFactory, default_locale_negotiator\n from pyramid.threadlocal import get_current_request\n \n-KNOWN_LOCALES = {\"en\": \"English\"}\n+KNOWN_LOCALES = {\"en\": \"English\", \"pt_BR\": \"Portuguese (Brazil)\"}\n \n LOCALE_ATTR = \"_LOCALE_\"\n", "issue": "Add Brazilian Portugese to localization footer\nhttps://hosted.weblate.org/projects/pypa/warehouse/#translations says that we're now at 100% translated for Brazilian Portugese. Therefore, let's insert the footer of available locales/translations per #6624, and add Brazilian Portugese.\r\n\r\n@yeraydiazdiaz @nlhkabu can either of you do this? Thanks.\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom babel.core import Locale\nfrom pyramid.i18n import TranslationStringFactory, default_locale_negotiator\nfrom pyramid.threadlocal import get_current_request\n\nKNOWN_LOCALES = {\"en\": \"English\"}\n\nLOCALE_ATTR = \"_LOCALE_\"\n\n_translation_factory = TranslationStringFactory(\"messages\")\n\n\nclass LazyString:\n    def __init__(self, fn, *args, **kwargs):\n        self.fn = fn\n        self.args = args\n        self.mapping = kwargs.get(\"mapping\", {})\n        self.kwargs = kwargs\n\n    def __json__(self, request):\n        return str(self)\n\n    def __mod__(self, new_mapping):\n        mapping = self.mapping.copy()\n        mapping.update(new_mapping)\n        return LazyString(self.fn, *self.args, mapping=new_mapping, **self.kwargs)\n\n    def __str__(self):\n        return self.fn(*self.args, **self.kwargs)\n\n\ndef _locale(request):\n    \"\"\"\n    Computes a babel.core:Locale() object for this request.\n    \"\"\"\n    return Locale.parse(request.locale_name, sep=\"_\")\n\n\ndef _negotiate_locale(request):\n    locale_name = getattr(request, LOCALE_ATTR, None)\n    if locale_name is not None:\n        return locale_name\n\n    locale_name = request.params.get(LOCALE_ATTR)\n    if locale_name is not None:\n        return locale_name\n\n    locale_name = request.cookies.get(LOCALE_ATTR)\n    if locale_name is not None:\n        return locale_name\n\n    if not request.accept_language:\n        return default_locale_negotiator(request)\n\n    return request.accept_language.best_match(\n        tuple(KNOWN_LOCALES.keys()), default_match=default_locale_negotiator(request)\n    )\n\n\ndef localize(message, **kwargs):\n    def _localize(message, **kwargs):\n        request = get_current_request()\n        return request.localizer.translate(_translation_factory(message, **kwargs))\n\n    return LazyString(_localize, message, **kwargs)\n\n\ndef includeme(config):\n    # Add the request attributes\n    config.add_request_method(_locale, name=\"locale\", reify=True)\n\n    # Register our translation directory.\n    config.add_translation_dirs(\"warehouse:locale/\")\n\n    config.set_locale_negotiator(_negotiate_locale)\n\n    # Register our i18n/l10n filters for Jinja2\n    filters = config.get_settings().setdefault(\"jinja2.filters\", {})\n    filters.setdefault(\"format_date\", \"warehouse.i18n.filters:format_date\")\n    filters.setdefault(\"format_datetime\", \"warehouse.i18n.filters:format_datetime\")\n    filters.setdefault(\n        \"format_rfc822_datetime\", \"warehouse.i18n.filters:format_rfc822_datetime\"\n    )\n    filters.setdefault(\"format_number\", \"warehouse.i18n.filters:format_number\")\n\n    jglobals = config.get_settings().setdefault(\"jinja2.globals\", {})\n    jglobals.setdefault(\"KNOWN_LOCALES\", \"warehouse.i18n:KNOWN_LOCALES\")\n", "path": "warehouse/i18n/__init__.py"}], "after_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom babel.core import Locale\nfrom pyramid.i18n import TranslationStringFactory, default_locale_negotiator\nfrom pyramid.threadlocal import get_current_request\n\nKNOWN_LOCALES = {\"en\": \"English\", \"pt_BR\": \"Portuguese (Brazil)\"}\n\nLOCALE_ATTR = \"_LOCALE_\"\n\n_translation_factory = TranslationStringFactory(\"messages\")\n\n\nclass LazyString:\n    def __init__(self, fn, *args, **kwargs):\n        self.fn = fn\n        self.args = args\n        self.mapping = kwargs.get(\"mapping\", {})\n        self.kwargs = kwargs\n\n    def __json__(self, request):\n        return str(self)\n\n    def __mod__(self, new_mapping):\n        mapping = self.mapping.copy()\n        mapping.update(new_mapping)\n        return LazyString(self.fn, *self.args, mapping=new_mapping, **self.kwargs)\n\n    def __str__(self):\n        return self.fn(*self.args, **self.kwargs)\n\n\ndef _locale(request):\n    \"\"\"\n    Computes a babel.core:Locale() object for this request.\n    \"\"\"\n    return Locale.parse(request.locale_name, sep=\"_\")\n\n\ndef _negotiate_locale(request):\n    locale_name = getattr(request, LOCALE_ATTR, None)\n    if locale_name is not None:\n        return locale_name\n\n    locale_name = request.params.get(LOCALE_ATTR)\n    if locale_name is not None:\n        return locale_name\n\n    locale_name = request.cookies.get(LOCALE_ATTR)\n    if locale_name is not None:\n        return locale_name\n\n    if not request.accept_language:\n        return default_locale_negotiator(request)\n\n    return request.accept_language.best_match(\n        tuple(KNOWN_LOCALES.keys()), default_match=default_locale_negotiator(request)\n    )\n\n\ndef localize(message, **kwargs):\n    def _localize(message, **kwargs):\n        request = get_current_request()\n        return request.localizer.translate(_translation_factory(message, **kwargs))\n\n    return LazyString(_localize, message, **kwargs)\n\n\ndef includeme(config):\n    # Add the request attributes\n    config.add_request_method(_locale, name=\"locale\", reify=True)\n\n    # Register our translation directory.\n    config.add_translation_dirs(\"warehouse:locale/\")\n\n    config.set_locale_negotiator(_negotiate_locale)\n\n    # Register our i18n/l10n filters for Jinja2\n    filters = config.get_settings().setdefault(\"jinja2.filters\", {})\n    filters.setdefault(\"format_date\", \"warehouse.i18n.filters:format_date\")\n    filters.setdefault(\"format_datetime\", \"warehouse.i18n.filters:format_datetime\")\n    filters.setdefault(\n        \"format_rfc822_datetime\", \"warehouse.i18n.filters:format_rfc822_datetime\"\n    )\n    filters.setdefault(\"format_number\", \"warehouse.i18n.filters:format_number\")\n\n    jglobals = config.get_settings().setdefault(\"jinja2.globals\", {})\n    jglobals.setdefault(\"KNOWN_LOCALES\", \"warehouse.i18n:KNOWN_LOCALES\")\n", "path": "warehouse/i18n/__init__.py"}]}