We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add Russian translation
The Russian Translation is at [100% on Weblate](https://hosted.weblate.org/languages/ru/pypa/) so I think it should be added to the localization footer.

--- 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 import functools
14 
15 from babel.core import Locale
16 from pyramid import viewderivers
17 from pyramid.i18n import TranslationStringFactory, default_locale_negotiator
18 from pyramid.threadlocal import get_current_request
19 
20 from warehouse.cache.http import add_vary
21 
22 # Taken from:
23 # https://github.com/django/django/blob/master/django/conf/locale/__init__.py
24 KNOWN_LOCALES = {
25     "en": "English",  # English
26     "es": "español",  # Spanish
27     "fr": "français",  # French
28     "ja": "日本語",  # Japanese
29     "pt_BR": "Português Brasileiro",  # Brazilian Portugeuse
30     "uk": "Українська",  # Ukrainian
31     "el": "Ελληνικά",  # Greek
32     "de": "Deutsch",  # German
33     "zh_Hans": "简体中文",  # Simplified Chinese
34 }
35 
36 LOCALE_ATTR = "_LOCALE_"
37 
38 _translation_factory = TranslationStringFactory("messages")
39 
40 
41 class LazyString:
42     def __init__(self, fn, *args, **kwargs):
43         self.fn = fn
44         self.args = args
45         self.mapping = kwargs.get("mapping", {})
46         self.kwargs = kwargs
47 
48     def __json__(self, request):
49         return str(self)
50 
51     def __mod__(self, new_mapping):
52         mapping = self.mapping.copy()
53         mapping.update(new_mapping)
54         return LazyString(self.fn, *self.args, mapping=new_mapping, **self.kwargs)
55 
56     def __str__(self):
57         return self.fn(*self.args, **self.kwargs)
58 
59 
60 def _locale(request):
61     """
62     Computes a babel.core:Locale() object for this request.
63     """
64     return Locale.parse(request.locale_name, sep="_")
65 
66 
67 def _negotiate_locale(request):
68     locale_name = getattr(request, LOCALE_ATTR, None)
69     if locale_name is not None:
70         return locale_name
71 
72     locale_name = request.params.get(LOCALE_ATTR)
73     if locale_name is not None:
74         return locale_name
75 
76     locale_name = request.cookies.get(LOCALE_ATTR)
77     if locale_name is not None:
78         return locale_name
79 
80     if not request.accept_language:
81         return default_locale_negotiator(request)
82 
83     return request.accept_language.best_match(
84         tuple(KNOWN_LOCALES.keys()), default_match=default_locale_negotiator(request)
85     )
86 
87 
88 def localize(message, **kwargs):
89     def _localize(message, **kwargs):
90         request = get_current_request()
91         return request.localizer.translate(_translation_factory(message, **kwargs))
92 
93     return LazyString(_localize, message, **kwargs)
94 
95 
96 class InvalidLocalizer:
97     def _fail(self):
98         raise RuntimeError("Cannot use localizer without has_translations=True")
99 
100     @property
101     def locale_name(self):
102         self._fail()
103 
104     def pluralize(self, *args, **kwargs):
105         self._fail()
106 
107     def translate(self, *args, **kwargs):
108         self._fail()
109 
110 
111 def translated_view(view, info):
112     if info.options.get("has_translations"):
113         # If this page can be translated, then we'll add a Vary: PyPI-Locale
114         #   Vary header.
115         # Note: This will give weird results if hitting PyPI directly instead of through
116         #       the Fastly VCL which sets PyPI-Locale.
117         return add_vary("PyPI-Locale")(view)
118     elif info.exception_only:
119         return view
120     else:
121         # If we're not using translations on this view, then we'll wrap the view
122         # with a wrapper that just ensures that the localizer cannot be used.
123         @functools.wraps(view)
124         def wrapped(context, request):
125             # This whole method is a little bit of an odd duck, we want to make
126             # sure that we don't actually *access* request.localizer, because
127             # doing so triggers the machinery to create a new localizer. So
128             # instead we will dig into the request object __dict__ to
129             # effectively do the same thing, just without triggering an access
130             # on request.localizer.
131 
132             # Save the original session so that we can restore it once the
133             # inner views have been called.
134             nothing = object()
135             original_localizer = request.__dict__.get("localizer", nothing)
136 
137             # This particular view hasn't been set to allow access to the
138             # translations, so we'll just assign an InvalidLocalizer to
139             # request.localizer
140             request.__dict__["localizer"] = InvalidLocalizer()
141 
142             try:
143                 # Invoke the real view
144                 return view(context, request)
145             finally:
146                 # Restore the original session so that things like
147                 # pyramid_debugtoolbar can access it.
148                 if original_localizer is nothing:
149                     del request.__dict__["localizer"]
150                 else:
151                     request.__dict__["localizer"] = original_localizer
152 
153         return wrapped
154 
155 
156 translated_view.options = {"has_translations"}
157 
158 
159 def includeme(config):
160     # Add the request attributes
161     config.add_request_method(_locale, name="locale", reify=True)
162 
163     # Register our translation directory.
164     config.add_translation_dirs("warehouse:locale/")
165 
166     config.set_locale_negotiator(_negotiate_locale)
167 
168     # Register our i18n/l10n filters for Jinja2
169     filters = config.get_settings().setdefault("jinja2.filters", {})
170     filters.setdefault("format_date", "warehouse.i18n.filters:format_date")
171     filters.setdefault("format_datetime", "warehouse.i18n.filters:format_datetime")
172     filters.setdefault(
173         "format_rfc822_datetime", "warehouse.i18n.filters:format_rfc822_datetime"
174     )
175     filters.setdefault("format_number", "warehouse.i18n.filters:format_number")
176 
177     jglobals = config.get_settings().setdefault("jinja2.globals", {})
178     jglobals.setdefault("KNOWN_LOCALES", "warehouse.i18n:KNOWN_LOCALES")
179 
180     config.add_view_deriver(
181         translated_view, over="rendered_view", under=viewderivers.INGRESS
182     )
183
```
--- 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
@@ -31,6 +31,7 @@
     "el": "Ελληνικά",  # Greek
     "de": "Deutsch",  # German
     "zh_Hans": "简体中文",  # Simplified Chinese
+    "ru": "Русский",  # Russian
 }
 
 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@@ -31,6 +31,7 @@\n     \"el\": \"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac\",  # Greek\n     \"de\": \"Deutsch\",  # German\n     \"zh_Hans\": \"\u7b80\u4f53\u4e2d\u6587\",  # Simplified Chinese\n+    \"ru\": \"\u0420\u0443\u0441\u0441\u043a\u0438\u0439\",  # Russian\n }\n \n LOCALE_ATTR = \"_LOCALE_\"\n", "issue": "Add Russian translation\nThe Russian Translation is at [100% on Weblate](https://hosted.weblate.org/languages/ru/pypa/) so I think it should be added to the localization footer.\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\nimport functools\n\nfrom babel.core import Locale\nfrom pyramid import viewderivers\nfrom pyramid.i18n import TranslationStringFactory, default_locale_negotiator\nfrom pyramid.threadlocal import get_current_request\n\nfrom warehouse.cache.http import add_vary\n\n# Taken from:\n# https://github.com/django/django/blob/master/django/conf/locale/__init__.py\nKNOWN_LOCALES = {\n    \"en\": \"English\",  # English\n    \"es\": \"espa\u00f1ol\",  # Spanish\n    \"fr\": \"fran\u00e7ais\",  # French\n    \"ja\": \"\u65e5\u672c\u8a9e\",  # Japanese\n    \"pt_BR\": \"Portugu\u00eas Brasileiro\",  # Brazilian Portugeuse\n    \"uk\": \"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430\",  # Ukrainian\n    \"el\": \"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac\",  # Greek\n    \"de\": \"Deutsch\",  # German\n    \"zh_Hans\": \"\u7b80\u4f53\u4e2d\u6587\",  # Simplified Chinese\n}\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\nclass InvalidLocalizer:\n    def _fail(self):\n        raise RuntimeError(\"Cannot use localizer without has_translations=True\")\n\n    @property\n    def locale_name(self):\n        self._fail()\n\n    def pluralize(self, *args, **kwargs):\n        self._fail()\n\n    def translate(self, *args, **kwargs):\n        self._fail()\n\n\ndef translated_view(view, info):\n    if info.options.get(\"has_translations\"):\n        # If this page can be translated, then we'll add a Vary: PyPI-Locale\n        #   Vary header.\n        # Note: This will give weird results if hitting PyPI directly instead of through\n        #       the Fastly VCL which sets PyPI-Locale.\n        return add_vary(\"PyPI-Locale\")(view)\n    elif info.exception_only:\n        return view\n    else:\n        # If we're not using translations on this view, then we'll wrap the view\n        # with a wrapper that just ensures that the localizer cannot be used.\n        @functools.wraps(view)\n        def wrapped(context, request):\n            # This whole method is a little bit of an odd duck, we want to make\n            # sure that we don't actually *access* request.localizer, because\n            # doing so triggers the machinery to create a new localizer. So\n            # instead we will dig into the request object __dict__ to\n            # effectively do the same thing, just without triggering an access\n            # on request.localizer.\n\n            # Save the original session so that we can restore it once the\n            # inner views have been called.\n            nothing = object()\n            original_localizer = request.__dict__.get(\"localizer\", nothing)\n\n            # This particular view hasn't been set to allow access to the\n            # translations, so we'll just assign an InvalidLocalizer to\n            # request.localizer\n            request.__dict__[\"localizer\"] = InvalidLocalizer()\n\n            try:\n                # Invoke the real view\n                return view(context, request)\n            finally:\n                # Restore the original session so that things like\n                # pyramid_debugtoolbar can access it.\n                if original_localizer is nothing:\n                    del request.__dict__[\"localizer\"]\n                else:\n                    request.__dict__[\"localizer\"] = original_localizer\n\n        return wrapped\n\n\ntranslated_view.options = {\"has_translations\"}\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\n    config.add_view_deriver(\n        translated_view, over=\"rendered_view\", under=viewderivers.INGRESS\n    )\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\nimport functools\n\nfrom babel.core import Locale\nfrom pyramid import viewderivers\nfrom pyramid.i18n import TranslationStringFactory, default_locale_negotiator\nfrom pyramid.threadlocal import get_current_request\n\nfrom warehouse.cache.http import add_vary\n\n# Taken from:\n# https://github.com/django/django/blob/master/django/conf/locale/__init__.py\nKNOWN_LOCALES = {\n    \"en\": \"English\",  # English\n    \"es\": \"espa\u00f1ol\",  # Spanish\n    \"fr\": \"fran\u00e7ais\",  # French\n    \"ja\": \"\u65e5\u672c\u8a9e\",  # Japanese\n    \"pt_BR\": \"Portugu\u00eas Brasileiro\",  # Brazilian Portugeuse\n    \"uk\": \"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430\",  # Ukrainian\n    \"el\": \"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac\",  # Greek\n    \"de\": \"Deutsch\",  # German\n    \"zh_Hans\": \"\u7b80\u4f53\u4e2d\u6587\",  # Simplified Chinese\n    \"ru\": \"\u0420\u0443\u0441\u0441\u043a\u0438\u0439\",  # Russian\n}\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\nclass InvalidLocalizer:\n    def _fail(self):\n        raise RuntimeError(\"Cannot use localizer without has_translations=True\")\n\n    @property\n    def locale_name(self):\n        self._fail()\n\n    def pluralize(self, *args, **kwargs):\n        self._fail()\n\n    def translate(self, *args, **kwargs):\n        self._fail()\n\n\ndef translated_view(view, info):\n    if info.options.get(\"has_translations\"):\n        # If this page can be translated, then we'll add a Vary: PyPI-Locale\n        #   Vary header.\n        # Note: This will give weird results if hitting PyPI directly instead of through\n        #       the Fastly VCL which sets PyPI-Locale.\n        return add_vary(\"PyPI-Locale\")(view)\n    elif info.exception_only:\n        return view\n    else:\n        # If we're not using translations on this view, then we'll wrap the view\n        # with a wrapper that just ensures that the localizer cannot be used.\n        @functools.wraps(view)\n        def wrapped(context, request):\n            # This whole method is a little bit of an odd duck, we want to make\n            # sure that we don't actually *access* request.localizer, because\n            # doing so triggers the machinery to create a new localizer. So\n            # instead we will dig into the request object __dict__ to\n            # effectively do the same thing, just without triggering an access\n            # on request.localizer.\n\n            # Save the original session so that we can restore it once the\n            # inner views have been called.\n            nothing = object()\n            original_localizer = request.__dict__.get(\"localizer\", nothing)\n\n            # This particular view hasn't been set to allow access to the\n            # translations, so we'll just assign an InvalidLocalizer to\n            # request.localizer\n            request.__dict__[\"localizer\"] = InvalidLocalizer()\n\n            try:\n                # Invoke the real view\n                return view(context, request)\n            finally:\n                # Restore the original session so that things like\n                # pyramid_debugtoolbar can access it.\n                if original_localizer is nothing:\n                    del request.__dict__[\"localizer\"]\n                else:\n                    request.__dict__[\"localizer\"] = original_localizer\n\n        return wrapped\n\n\ntranslated_view.options = {\"has_translations\"}\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\n    config.add_view_deriver(\n        translated_view, over=\"rendered_view\", under=viewderivers.INGRESS\n    )\n", "path": "warehouse/i18n/__init__.py"}]}