We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Plural strings not marked as that
While reviewing strings for 2.8 release, those are not in plural forms:

- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826598
- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826597
- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826594
- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826584

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pootle/apps/pootle_language/views.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) Pootle contributors.
4 #
5 # This file is a part of the Pootle project. It is distributed under the GPL3
6 # or later license. See the LICENSE file for a copy of the license and the
7 # AUTHORS file for copyright and authorship information.
8 
9 from django.contrib import messages
10 from django.http import Http404
11 from django.shortcuts import redirect, render
12 from django.urls import reverse
13 from django.utils.functional import cached_property
14 from django.utils.lru_cache import lru_cache
15 from django.utils.safestring import mark_safe
16 
17 from pootle.core.browser import make_project_item
18 from pootle.core.decorators import (
19     get_object_or_404, get_path_obj, permission_required)
20 from pootle.core.views import PootleBrowseView, PootleTranslateView
21 from pootle.core.views.admin import PootleFormView
22 from pootle.core.views.decorators import requires_permission, set_permissions
23 from pootle.core.views.formtable import Formtable
24 from pootle.core.views.mixins import PootleJSONMixin
25 from pootle.i18n import formatter
26 from pootle.i18n.gettext import tr_lang, ugettext_lazy as _
27 from pootle_misc.util import cmp_by_last_activity
28 from pootle_store.constants import STATES_MAP
29 
30 from .apps import PootleLanguageConfig
31 from .forms import (
32     LanguageSpecialCharsForm, LanguageSuggestionAdminForm, LanguageTeamAdminForm,
33     LanguageTeamNewMemberSearchForm)
34 from .models import Language
35 
36 
37 class LanguageMixin(object):
38     ns = "pootle.language"
39     sw_version = PootleLanguageConfig.version
40     model = Language
41     browse_url_path = "pootle-language-browse"
42     translate_url_path = "pootle-language-translate"
43     template_extends = 'languages/base.html'
44 
45     @property
46     def language(self):
47         return self.object
48 
49     @property
50     def permission_context(self):
51         return self.get_object().directory
52 
53     @property
54     def url_kwargs(self):
55         return {"language_code": self.object.code}
56 
57     @lru_cache()
58     def get_object(self):
59         lang = Language.get_canonical(self.kwargs["language_code"])
60         if lang is None:
61             raise Http404
62         return lang
63 
64     def get(self, *args, **kwargs):
65         self.object = self.get_object()
66         if self.object.code != kwargs["language_code"]:
67             return redirect(
68                 self.url_pattern_name,
69                 self.object.code,
70                 permanent=True)
71         return super(LanguageMixin, self).get(*args, **kwargs)
72 
73 
74 class LanguageBrowseView(LanguageMixin, PootleBrowseView):
75     url_pattern_name = "pootle-language-browse"
76     view_name = "language"
77 
78     @cached_property
79     def object_children(self):
80         items = [make_project_item(tp)
81                  for tp in self.object.get_children_for_user(self.request.user)]
82         items = self.add_child_stats(items)
83         items.sort(cmp_by_last_activity)
84         return items
85 
86     @property
87     def language(self):
88         return {
89             'code': self.object.code,
90             'name': tr_lang(self.object.fullname)}
91 
92     def get(self, *args, **kwargs):
93         response = super(LanguageBrowseView, self).get(*args, **kwargs)
94         response.set_cookie('pootle-language', self.object.code)
95         return response
96 
97 
98 class LanguageTranslateView(LanguageMixin, PootleTranslateView):
99     url_pattern_name = "pootle-language-translate"
100 
101 
102 @get_path_obj
103 @permission_required('administrate')
104 def language_characters_admin(request, language):
105     form = LanguageSpecialCharsForm(request.POST
106                                     if request.method == 'POST'
107                                     else None,
108                                     instance=language)
109     if form.is_valid():
110         form.save()
111         return redirect('pootle-language-browse', language.code)
112 
113     ctx = {
114         'page': 'admin-characters',
115 
116         'browse_url': reverse('pootle-language-browse', kwargs={
117             'language_code': language.code,
118         }),
119         'translate_url': reverse('pootle-language-translate', kwargs={
120             'language_code': language.code,
121         }),
122 
123         'language': language,
124         'directory': language.directory,
125         'form': form,
126     }
127 
128     return render(request, 'languages/admin/characters.html', ctx)
129 
130 
131 class SuggestionFormtable(Formtable):
132     row_field = "suggestions"
133     filters_template = "languages/admin/includes/suggestions_header.html"
134 
135     @property
136     def messages(self):
137         return self.kwargs.get("messages", [])
138 
139 
140 class SuggestionDisplay(object):
141 
142     def __init__(self, suggestion):
143         self.__suggestion__ = suggestion
144 
145     @property
146     def unit(self):
147         return self.__suggestion__.unit.source_f
148 
149     @property
150     def project(self):
151         tp = self.__suggestion__.unit.store.translation_project
152         return mark_safe(
153             "<a href='%s'>%s</a>"
154             % (tp.get_absolute_url(),
155                tp.project.code))
156 
157     @property
158     def unit_state(self):
159         return STATES_MAP[self.__suggestion__.unit.state]
160 
161     @property
162     def unit_link(self):
163         return mark_safe(
164             "<a href='%s'>#%s</a>"
165             % (self.__suggestion__.unit.get_translate_url(),
166                self.__suggestion__.unit.id))
167 
168     def __getattr__(self, k):
169         try:
170             return getattr(self.__suggestion__, k)
171         except AttributeError:
172             return self.__getattribute__(k)
173 
174 
175 class PootleLanguageAdminFormView(PootleFormView):
176 
177     @property
178     def permission_context(self):
179         return self.language.directory
180 
181     @set_permissions
182     @requires_permission("administrate")
183     def dispatch(self, request, *args, **kwargs):
184         # get funky with the request 8/
185         return super(
186             PootleLanguageAdminFormView, self).dispatch(request, *args, **kwargs)
187 
188     @cached_property
189     def language(self):
190         return get_object_or_404(
191             Language.objects.select_related("directory"),
192             code=self.kwargs["language_code"])
193 
194     def get_form_kwargs(self):
195         kwargs = super(PootleLanguageAdminFormView, self).get_form_kwargs()
196         kwargs["language"] = self.language
197         return kwargs
198 
199     @property
200     def success_kwargs(self):
201         return dict(language_code=self.language.code)
202 
203 
204 class LanguageSuggestionAdminView(PootleLanguageAdminFormView):
205     template_name = 'languages/admin/language_team_suggestions.html'
206     form_class = LanguageSuggestionAdminForm
207     success_url_pattern = "pootle-language-admin-suggestions"
208     formtable_columns = (
209         _("Unit"),
210         _("State"),
211         _("Source"),
212         _("Suggestion"),
213         _("Suggested by"),
214         _("Suggested at"),
215         _("Project"))
216 
217     @property
218     def default_form_kwargs(self):
219         return dict(
220             page_no=1,
221             results_per_page=10)
222 
223     def add_success_message(self, form):
224         count = (
225             form.fields["suggestions"].queryset.count()
226             if form.cleaned_data["select_all"]
227             else len(form.cleaned_data["suggestions"]))
228         reject_and_notify = (
229             form.cleaned_data["actions"] == "reject"
230             and form.cleaned_data["comment"])
231         accept_and_notify = (
232             form.cleaned_data["actions"] == "accept"
233             and form.cleaned_data["comment"])
234         if reject_and_notify:
235             message = _(
236                 "Rejected %s suggestions with comment. Users will be notified",
237                 count)
238         elif accept_and_notify:
239             message = _(
240                 "Accepted %s suggestions with comment. Users will be notified",
241                 count)
242         elif form.cleaned_data["actions"] == "reject":
243             message = _("Rejected %s suggestions", count)
244         else:
245             message = _("Accepted %s suggestions", count)
246         messages.success(self.request, message)
247 
248     def get_context_data(self, **kwargs):
249         context = super(
250             LanguageSuggestionAdminView, self).get_context_data(**kwargs)
251         context["page"] = "admin-suggestions"
252         context["language"] = self.language
253         form = context["form"]
254         form.is_valid()
255         batch = form.batch()
256         form.fields["suggestions"].choices = [
257             (item.id, SuggestionDisplay(item))
258             for item in
259             batch.object_list]
260         context["formtable"] = SuggestionFormtable(
261             form,
262             columns=self.formtable_columns,
263             page=batch,
264             messages=messages.get_messages(self.request))
265         return context
266 
267     def get_form_kwargs(self):
268         kwargs = super(LanguageSuggestionAdminView, self).get_form_kwargs()
269         if not self.request.POST:
270             kwargs["data"] = self.default_form_kwargs
271         kwargs["user"] = self.request.user
272         return kwargs
273 
274 
275 class LanguageTeamAdminFormView(PootleLanguageAdminFormView):
276     form_class = LanguageTeamAdminForm
277     template_name = "languages/admin/language_team.html"
278     success_url_pattern = "pootle-language-admin-team"
279 
280     def get_context_data(self, **kwargs):
281         context = super(LanguageTeamAdminFormView, self).get_context_data(**kwargs)
282         form = context["form"]
283         context["tps"] = self.language.translationproject_set.exclude(
284             project__disabled=True)
285         stats = self.language.data_tool.get_stats(
286             include_children=False,
287             user=self.request.user)
288         keys = ("total", "critical", "incomplete", "translated", "fuzzy",
289                 "untranslated")
290         for k in keys:
291             if k in stats:
292                 stats[k + "_display"] = formatter.number(stats[k])
293         context["stats"] = stats
294         context["suggestions"] = form.language_team.suggestions
295         suggestions_count = 0
296         if context["suggestions"]:
297             suggestions_count = context["suggestions"].count()
298         context["suggestions_display"] = formatter.number(suggestions_count)
299         context["language"] = self.language
300         context["page"] = "admin-team"
301         context["browse_url"] = reverse(
302             "pootle-language-browse",
303             kwargs=dict(language_code=self.language.code))
304         context["translate_url"] = reverse(
305             "pootle-language-translate",
306             kwargs=dict(language_code=self.language.code))
307         return context
308 
309 
310 class LanguageTeamAdminNewMembersJSON(PootleJSONMixin, PootleLanguageAdminFormView):
311     form_class = LanguageTeamNewMemberSearchForm
312 
313     def get_context_data(self, **kwargs):
314         context = super(
315             LanguageTeamAdminNewMembersJSON, self).get_context_data(**kwargs)
316         form = context["form"]
317         return (
318             dict(items=form.search())
319             if form.is_valid()
320             else dict(items=[]))
321 
322     def get_form_kwargs(self):
323         kwargs = super(LanguageTeamAdminNewMembersJSON, self).get_form_kwargs()
324         kwargs["data"] = self.request.GET
325         return kwargs
326
```
--- 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/pootle/apps/pootle_language/views.py b/pootle/apps/pootle_language/views.py
--- a/pootle/apps/pootle_language/views.py
+++ b/pootle/apps/pootle_language/views.py
@@ -23,7 +23,7 @@
 from pootle.core.views.formtable import Formtable
 from pootle.core.views.mixins import PootleJSONMixin
 from pootle.i18n import formatter
-from pootle.i18n.gettext import tr_lang, ugettext_lazy as _
+from pootle.i18n.gettext import tr_lang, ugettext_lazy as _, ungettext_lazy
 from pootle_misc.util import cmp_by_last_activity
 from pootle_store.constants import STATES_MAP
 
@@ -232,17 +232,25 @@
             form.cleaned_data["actions"] == "accept"
             and form.cleaned_data["comment"])
         if reject_and_notify:
-            message = _(
+            message = ungettext_lazy(
+                "Rejected %s suggestion with comment. User will be notified",
                 "Rejected %s suggestions with comment. Users will be notified",
                 count)
         elif accept_and_notify:
-            message = _(
+            message = ungettext_lazy(
+                "Accepted %s suggestion with comment. User will be notified",
                 "Accepted %s suggestions with comment. Users will be notified",
                 count)
         elif form.cleaned_data["actions"] == "reject":
-            message = _("Rejected %s suggestions", count)
+            message = ungettext_lazy(
+                "Rejected %s suggestion",
+                "Rejected %s suggestions",
+                count)
         else:
-            message = _("Accepted %s suggestions", count)
+            message = ungettext_lazy(
+                "Accepted %s suggestion",
+                "Accepted %s suggestions",
+                count)
         messages.success(self.request, message)
 
     def get_context_data(self, **kwargs):

{"golden_diff": "diff --git a/pootle/apps/pootle_language/views.py b/pootle/apps/pootle_language/views.py\n--- a/pootle/apps/pootle_language/views.py\n+++ b/pootle/apps/pootle_language/views.py\n@@ -23,7 +23,7 @@\n from pootle.core.views.formtable import Formtable\n from pootle.core.views.mixins import PootleJSONMixin\n from pootle.i18n import formatter\n-from pootle.i18n.gettext import tr_lang, ugettext_lazy as _\n+from pootle.i18n.gettext import tr_lang, ugettext_lazy as _, ungettext_lazy\n from pootle_misc.util import cmp_by_last_activity\n from pootle_store.constants import STATES_MAP\n \n@@ -232,17 +232,25 @@\n             form.cleaned_data[\"actions\"] == \"accept\"\n             and form.cleaned_data[\"comment\"])\n         if reject_and_notify:\n-            message = _(\n+            message = ungettext_lazy(\n+                \"Rejected %s suggestion with comment. User will be notified\",\n                 \"Rejected %s suggestions with comment. Users will be notified\",\n                 count)\n         elif accept_and_notify:\n-            message = _(\n+            message = ungettext_lazy(\n+                \"Accepted %s suggestion with comment. User will be notified\",\n                 \"Accepted %s suggestions with comment. Users will be notified\",\n                 count)\n         elif form.cleaned_data[\"actions\"] == \"reject\":\n-            message = _(\"Rejected %s suggestions\", count)\n+            message = ungettext_lazy(\n+                \"Rejected %s suggestion\",\n+                \"Rejected %s suggestions\",\n+                count)\n         else:\n-            message = _(\"Accepted %s suggestions\", count)\n+            message = ungettext_lazy(\n+                \"Accepted %s suggestion\",\n+                \"Accepted %s suggestions\",\n+                count)\n         messages.success(self.request, message)\n \n     def get_context_data(self, **kwargs):\n", "issue": "Plural strings not marked as that\nWhile reviewing strings for 2.8 release, those are not in plural forms:\r\n\r\n- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826598\r\n- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826597\r\n- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826594\r\n- http://pootle.locamotion.org/ar/pootle/translate/pootle.po#unit=1826584\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.contrib import messages\nfrom django.http import Http404\nfrom django.shortcuts import redirect, render\nfrom django.urls import reverse\nfrom django.utils.functional import cached_property\nfrom django.utils.lru_cache import lru_cache\nfrom django.utils.safestring import mark_safe\n\nfrom pootle.core.browser import make_project_item\nfrom pootle.core.decorators import (\n    get_object_or_404, get_path_obj, permission_required)\nfrom pootle.core.views import PootleBrowseView, PootleTranslateView\nfrom pootle.core.views.admin import PootleFormView\nfrom pootle.core.views.decorators import requires_permission, set_permissions\nfrom pootle.core.views.formtable import Formtable\nfrom pootle.core.views.mixins import PootleJSONMixin\nfrom pootle.i18n import formatter\nfrom pootle.i18n.gettext import tr_lang, ugettext_lazy as _\nfrom pootle_misc.util import cmp_by_last_activity\nfrom pootle_store.constants import STATES_MAP\n\nfrom .apps import PootleLanguageConfig\nfrom .forms import (\n    LanguageSpecialCharsForm, LanguageSuggestionAdminForm, LanguageTeamAdminForm,\n    LanguageTeamNewMemberSearchForm)\nfrom .models import Language\n\n\nclass LanguageMixin(object):\n    ns = \"pootle.language\"\n    sw_version = PootleLanguageConfig.version\n    model = Language\n    browse_url_path = \"pootle-language-browse\"\n    translate_url_path = \"pootle-language-translate\"\n    template_extends = 'languages/base.html'\n\n    @property\n    def language(self):\n        return self.object\n\n    @property\n    def permission_context(self):\n        return self.get_object().directory\n\n    @property\n    def url_kwargs(self):\n        return {\"language_code\": self.object.code}\n\n    @lru_cache()\n    def get_object(self):\n        lang = Language.get_canonical(self.kwargs[\"language_code\"])\n        if lang is None:\n            raise Http404\n        return lang\n\n    def get(self, *args, **kwargs):\n        self.object = self.get_object()\n        if self.object.code != kwargs[\"language_code\"]:\n            return redirect(\n                self.url_pattern_name,\n                self.object.code,\n                permanent=True)\n        return super(LanguageMixin, self).get(*args, **kwargs)\n\n\nclass LanguageBrowseView(LanguageMixin, PootleBrowseView):\n    url_pattern_name = \"pootle-language-browse\"\n    view_name = \"language\"\n\n    @cached_property\n    def object_children(self):\n        items = [make_project_item(tp)\n                 for tp in self.object.get_children_for_user(self.request.user)]\n        items = self.add_child_stats(items)\n        items.sort(cmp_by_last_activity)\n        return items\n\n    @property\n    def language(self):\n        return {\n            'code': self.object.code,\n            'name': tr_lang(self.object.fullname)}\n\n    def get(self, *args, **kwargs):\n        response = super(LanguageBrowseView, self).get(*args, **kwargs)\n        response.set_cookie('pootle-language', self.object.code)\n        return response\n\n\nclass LanguageTranslateView(LanguageMixin, PootleTranslateView):\n    url_pattern_name = \"pootle-language-translate\"\n\n\n@get_path_obj\n@permission_required('administrate')\ndef language_characters_admin(request, language):\n    form = LanguageSpecialCharsForm(request.POST\n                                    if request.method == 'POST'\n                                    else None,\n                                    instance=language)\n    if form.is_valid():\n        form.save()\n        return redirect('pootle-language-browse', language.code)\n\n    ctx = {\n        'page': 'admin-characters',\n\n        'browse_url': reverse('pootle-language-browse', kwargs={\n            'language_code': language.code,\n        }),\n        'translate_url': reverse('pootle-language-translate', kwargs={\n            'language_code': language.code,\n        }),\n\n        'language': language,\n        'directory': language.directory,\n        'form': form,\n    }\n\n    return render(request, 'languages/admin/characters.html', ctx)\n\n\nclass SuggestionFormtable(Formtable):\n    row_field = \"suggestions\"\n    filters_template = \"languages/admin/includes/suggestions_header.html\"\n\n    @property\n    def messages(self):\n        return self.kwargs.get(\"messages\", [])\n\n\nclass SuggestionDisplay(object):\n\n    def __init__(self, suggestion):\n        self.__suggestion__ = suggestion\n\n    @property\n    def unit(self):\n        return self.__suggestion__.unit.source_f\n\n    @property\n    def project(self):\n        tp = self.__suggestion__.unit.store.translation_project\n        return mark_safe(\n            \"<a href='%s'>%s</a>\"\n            % (tp.get_absolute_url(),\n               tp.project.code))\n\n    @property\n    def unit_state(self):\n        return STATES_MAP[self.__suggestion__.unit.state]\n\n    @property\n    def unit_link(self):\n        return mark_safe(\n            \"<a href='%s'>#%s</a>\"\n            % (self.__suggestion__.unit.get_translate_url(),\n               self.__suggestion__.unit.id))\n\n    def __getattr__(self, k):\n        try:\n            return getattr(self.__suggestion__, k)\n        except AttributeError:\n            return self.__getattribute__(k)\n\n\nclass PootleLanguageAdminFormView(PootleFormView):\n\n    @property\n    def permission_context(self):\n        return self.language.directory\n\n    @set_permissions\n    @requires_permission(\"administrate\")\n    def dispatch(self, request, *args, **kwargs):\n        # get funky with the request 8/\n        return super(\n            PootleLanguageAdminFormView, self).dispatch(request, *args, **kwargs)\n\n    @cached_property\n    def language(self):\n        return get_object_or_404(\n            Language.objects.select_related(\"directory\"),\n            code=self.kwargs[\"language_code\"])\n\n    def get_form_kwargs(self):\n        kwargs = super(PootleLanguageAdminFormView, self).get_form_kwargs()\n        kwargs[\"language\"] = self.language\n        return kwargs\n\n    @property\n    def success_kwargs(self):\n        return dict(language_code=self.language.code)\n\n\nclass LanguageSuggestionAdminView(PootleLanguageAdminFormView):\n    template_name = 'languages/admin/language_team_suggestions.html'\n    form_class = LanguageSuggestionAdminForm\n    success_url_pattern = \"pootle-language-admin-suggestions\"\n    formtable_columns = (\n        _(\"Unit\"),\n        _(\"State\"),\n        _(\"Source\"),\n        _(\"Suggestion\"),\n        _(\"Suggested by\"),\n        _(\"Suggested at\"),\n        _(\"Project\"))\n\n    @property\n    def default_form_kwargs(self):\n        return dict(\n            page_no=1,\n            results_per_page=10)\n\n    def add_success_message(self, form):\n        count = (\n            form.fields[\"suggestions\"].queryset.count()\n            if form.cleaned_data[\"select_all\"]\n            else len(form.cleaned_data[\"suggestions\"]))\n        reject_and_notify = (\n            form.cleaned_data[\"actions\"] == \"reject\"\n            and form.cleaned_data[\"comment\"])\n        accept_and_notify = (\n            form.cleaned_data[\"actions\"] == \"accept\"\n            and form.cleaned_data[\"comment\"])\n        if reject_and_notify:\n            message = _(\n                \"Rejected %s suggestions with comment. Users will be notified\",\n                count)\n        elif accept_and_notify:\n            message = _(\n                \"Accepted %s suggestions with comment. Users will be notified\",\n                count)\n        elif form.cleaned_data[\"actions\"] == \"reject\":\n            message = _(\"Rejected %s suggestions\", count)\n        else:\n            message = _(\"Accepted %s suggestions\", count)\n        messages.success(self.request, message)\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            LanguageSuggestionAdminView, self).get_context_data(**kwargs)\n        context[\"page\"] = \"admin-suggestions\"\n        context[\"language\"] = self.language\n        form = context[\"form\"]\n        form.is_valid()\n        batch = form.batch()\n        form.fields[\"suggestions\"].choices = [\n            (item.id, SuggestionDisplay(item))\n            for item in\n            batch.object_list]\n        context[\"formtable\"] = SuggestionFormtable(\n            form,\n            columns=self.formtable_columns,\n            page=batch,\n            messages=messages.get_messages(self.request))\n        return context\n\n    def get_form_kwargs(self):\n        kwargs = super(LanguageSuggestionAdminView, self).get_form_kwargs()\n        if not self.request.POST:\n            kwargs[\"data\"] = self.default_form_kwargs\n        kwargs[\"user\"] = self.request.user\n        return kwargs\n\n\nclass LanguageTeamAdminFormView(PootleLanguageAdminFormView):\n    form_class = LanguageTeamAdminForm\n    template_name = \"languages/admin/language_team.html\"\n    success_url_pattern = \"pootle-language-admin-team\"\n\n    def get_context_data(self, **kwargs):\n        context = super(LanguageTeamAdminFormView, self).get_context_data(**kwargs)\n        form = context[\"form\"]\n        context[\"tps\"] = self.language.translationproject_set.exclude(\n            project__disabled=True)\n        stats = self.language.data_tool.get_stats(\n            include_children=False,\n            user=self.request.user)\n        keys = (\"total\", \"critical\", \"incomplete\", \"translated\", \"fuzzy\",\n                \"untranslated\")\n        for k in keys:\n            if k in stats:\n                stats[k + \"_display\"] = formatter.number(stats[k])\n        context[\"stats\"] = stats\n        context[\"suggestions\"] = form.language_team.suggestions\n        suggestions_count = 0\n        if context[\"suggestions\"]:\n            suggestions_count = context[\"suggestions\"].count()\n        context[\"suggestions_display\"] = formatter.number(suggestions_count)\n        context[\"language\"] = self.language\n        context[\"page\"] = \"admin-team\"\n        context[\"browse_url\"] = reverse(\n            \"pootle-language-browse\",\n            kwargs=dict(language_code=self.language.code))\n        context[\"translate_url\"] = reverse(\n            \"pootle-language-translate\",\n            kwargs=dict(language_code=self.language.code))\n        return context\n\n\nclass LanguageTeamAdminNewMembersJSON(PootleJSONMixin, PootleLanguageAdminFormView):\n    form_class = LanguageTeamNewMemberSearchForm\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            LanguageTeamAdminNewMembersJSON, self).get_context_data(**kwargs)\n        form = context[\"form\"]\n        return (\n            dict(items=form.search())\n            if form.is_valid()\n            else dict(items=[]))\n\n    def get_form_kwargs(self):\n        kwargs = super(LanguageTeamAdminNewMembersJSON, self).get_form_kwargs()\n        kwargs[\"data\"] = self.request.GET\n        return kwargs\n", "path": "pootle/apps/pootle_language/views.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.contrib import messages\nfrom django.http import Http404\nfrom django.shortcuts import redirect, render\nfrom django.urls import reverse\nfrom django.utils.functional import cached_property\nfrom django.utils.lru_cache import lru_cache\nfrom django.utils.safestring import mark_safe\n\nfrom pootle.core.browser import make_project_item\nfrom pootle.core.decorators import (\n    get_object_or_404, get_path_obj, permission_required)\nfrom pootle.core.views import PootleBrowseView, PootleTranslateView\nfrom pootle.core.views.admin import PootleFormView\nfrom pootle.core.views.decorators import requires_permission, set_permissions\nfrom pootle.core.views.formtable import Formtable\nfrom pootle.core.views.mixins import PootleJSONMixin\nfrom pootle.i18n import formatter\nfrom pootle.i18n.gettext import tr_lang, ugettext_lazy as _, ungettext_lazy\nfrom pootle_misc.util import cmp_by_last_activity\nfrom pootle_store.constants import STATES_MAP\n\nfrom .apps import PootleLanguageConfig\nfrom .forms import (\n    LanguageSpecialCharsForm, LanguageSuggestionAdminForm, LanguageTeamAdminForm,\n    LanguageTeamNewMemberSearchForm)\nfrom .models import Language\n\n\nclass LanguageMixin(object):\n    ns = \"pootle.language\"\n    sw_version = PootleLanguageConfig.version\n    model = Language\n    browse_url_path = \"pootle-language-browse\"\n    translate_url_path = \"pootle-language-translate\"\n    template_extends = 'languages/base.html'\n\n    @property\n    def language(self):\n        return self.object\n\n    @property\n    def permission_context(self):\n        return self.get_object().directory\n\n    @property\n    def url_kwargs(self):\n        return {\"language_code\": self.object.code}\n\n    @lru_cache()\n    def get_object(self):\n        lang = Language.get_canonical(self.kwargs[\"language_code\"])\n        if lang is None:\n            raise Http404\n        return lang\n\n    def get(self, *args, **kwargs):\n        self.object = self.get_object()\n        if self.object.code != kwargs[\"language_code\"]:\n            return redirect(\n                self.url_pattern_name,\n                self.object.code,\n                permanent=True)\n        return super(LanguageMixin, self).get(*args, **kwargs)\n\n\nclass LanguageBrowseView(LanguageMixin, PootleBrowseView):\n    url_pattern_name = \"pootle-language-browse\"\n    view_name = \"language\"\n\n    @cached_property\n    def object_children(self):\n        items = [make_project_item(tp)\n                 for tp in self.object.get_children_for_user(self.request.user)]\n        items = self.add_child_stats(items)\n        items.sort(cmp_by_last_activity)\n        return items\n\n    @property\n    def language(self):\n        return {\n            'code': self.object.code,\n            'name': tr_lang(self.object.fullname)}\n\n    def get(self, *args, **kwargs):\n        response = super(LanguageBrowseView, self).get(*args, **kwargs)\n        response.set_cookie('pootle-language', self.object.code)\n        return response\n\n\nclass LanguageTranslateView(LanguageMixin, PootleTranslateView):\n    url_pattern_name = \"pootle-language-translate\"\n\n\n@get_path_obj\n@permission_required('administrate')\ndef language_characters_admin(request, language):\n    form = LanguageSpecialCharsForm(request.POST\n                                    if request.method == 'POST'\n                                    else None,\n                                    instance=language)\n    if form.is_valid():\n        form.save()\n        return redirect('pootle-language-browse', language.code)\n\n    ctx = {\n        'page': 'admin-characters',\n\n        'browse_url': reverse('pootle-language-browse', kwargs={\n            'language_code': language.code,\n        }),\n        'translate_url': reverse('pootle-language-translate', kwargs={\n            'language_code': language.code,\n        }),\n\n        'language': language,\n        'directory': language.directory,\n        'form': form,\n    }\n\n    return render(request, 'languages/admin/characters.html', ctx)\n\n\nclass SuggestionFormtable(Formtable):\n    row_field = \"suggestions\"\n    filters_template = \"languages/admin/includes/suggestions_header.html\"\n\n    @property\n    def messages(self):\n        return self.kwargs.get(\"messages\", [])\n\n\nclass SuggestionDisplay(object):\n\n    def __init__(self, suggestion):\n        self.__suggestion__ = suggestion\n\n    @property\n    def unit(self):\n        return self.__suggestion__.unit.source_f\n\n    @property\n    def project(self):\n        tp = self.__suggestion__.unit.store.translation_project\n        return mark_safe(\n            \"<a href='%s'>%s</a>\"\n            % (tp.get_absolute_url(),\n               tp.project.code))\n\n    @property\n    def unit_state(self):\n        return STATES_MAP[self.__suggestion__.unit.state]\n\n    @property\n    def unit_link(self):\n        return mark_safe(\n            \"<a href='%s'>#%s</a>\"\n            % (self.__suggestion__.unit.get_translate_url(),\n               self.__suggestion__.unit.id))\n\n    def __getattr__(self, k):\n        try:\n            return getattr(self.__suggestion__, k)\n        except AttributeError:\n            return self.__getattribute__(k)\n\n\nclass PootleLanguageAdminFormView(PootleFormView):\n\n    @property\n    def permission_context(self):\n        return self.language.directory\n\n    @set_permissions\n    @requires_permission(\"administrate\")\n    def dispatch(self, request, *args, **kwargs):\n        # get funky with the request 8/\n        return super(\n            PootleLanguageAdminFormView, self).dispatch(request, *args, **kwargs)\n\n    @cached_property\n    def language(self):\n        return get_object_or_404(\n            Language.objects.select_related(\"directory\"),\n            code=self.kwargs[\"language_code\"])\n\n    def get_form_kwargs(self):\n        kwargs = super(PootleLanguageAdminFormView, self).get_form_kwargs()\n        kwargs[\"language\"] = self.language\n        return kwargs\n\n    @property\n    def success_kwargs(self):\n        return dict(language_code=self.language.code)\n\n\nclass LanguageSuggestionAdminView(PootleLanguageAdminFormView):\n    template_name = 'languages/admin/language_team_suggestions.html'\n    form_class = LanguageSuggestionAdminForm\n    success_url_pattern = \"pootle-language-admin-suggestions\"\n    formtable_columns = (\n        _(\"Unit\"),\n        _(\"State\"),\n        _(\"Source\"),\n        _(\"Suggestion\"),\n        _(\"Suggested by\"),\n        _(\"Suggested at\"),\n        _(\"Project\"))\n\n    @property\n    def default_form_kwargs(self):\n        return dict(\n            page_no=1,\n            results_per_page=10)\n\n    def add_success_message(self, form):\n        count = (\n            form.fields[\"suggestions\"].queryset.count()\n            if form.cleaned_data[\"select_all\"]\n            else len(form.cleaned_data[\"suggestions\"]))\n        reject_and_notify = (\n            form.cleaned_data[\"actions\"] == \"reject\"\n            and form.cleaned_data[\"comment\"])\n        accept_and_notify = (\n            form.cleaned_data[\"actions\"] == \"accept\"\n            and form.cleaned_data[\"comment\"])\n        if reject_and_notify:\n            message = ungettext_lazy(\n                \"Rejected %s suggestion with comment. User will be notified\",\n                \"Rejected %s suggestions with comment. Users will be notified\",\n                count)\n        elif accept_and_notify:\n            message = ungettext_lazy(\n                \"Accepted %s suggestion with comment. User will be notified\",\n                \"Accepted %s suggestions with comment. Users will be notified\",\n                count)\n        elif form.cleaned_data[\"actions\"] == \"reject\":\n            message = ungettext_lazy(\n                \"Rejected %s suggestion\",\n                \"Rejected %s suggestions\",\n                count)\n        else:\n            message = ungettext_lazy(\n                \"Accepted %s suggestion\",\n                \"Accepted %s suggestions\",\n                count)\n        messages.success(self.request, message)\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            LanguageSuggestionAdminView, self).get_context_data(**kwargs)\n        context[\"page\"] = \"admin-suggestions\"\n        context[\"language\"] = self.language\n        form = context[\"form\"]\n        form.is_valid()\n        batch = form.batch()\n        form.fields[\"suggestions\"].choices = [\n            (item.id, SuggestionDisplay(item))\n            for item in\n            batch.object_list]\n        context[\"formtable\"] = SuggestionFormtable(\n            form,\n            columns=self.formtable_columns,\n            page=batch,\n            messages=messages.get_messages(self.request))\n        return context\n\n    def get_form_kwargs(self):\n        kwargs = super(LanguageSuggestionAdminView, self).get_form_kwargs()\n        if not self.request.POST:\n            kwargs[\"data\"] = self.default_form_kwargs\n        kwargs[\"user\"] = self.request.user\n        return kwargs\n\n\nclass LanguageTeamAdminFormView(PootleLanguageAdminFormView):\n    form_class = LanguageTeamAdminForm\n    template_name = \"languages/admin/language_team.html\"\n    success_url_pattern = \"pootle-language-admin-team\"\n\n    def get_context_data(self, **kwargs):\n        context = super(LanguageTeamAdminFormView, self).get_context_data(**kwargs)\n        form = context[\"form\"]\n        context[\"tps\"] = self.language.translationproject_set.exclude(\n            project__disabled=True)\n        stats = self.language.data_tool.get_stats(\n            include_children=False,\n            user=self.request.user)\n        keys = (\"total\", \"critical\", \"incomplete\", \"translated\", \"fuzzy\",\n                \"untranslated\")\n        for k in keys:\n            if k in stats:\n                stats[k + \"_display\"] = formatter.number(stats[k])\n        context[\"stats\"] = stats\n        context[\"suggestions\"] = form.language_team.suggestions\n        suggestions_count = 0\n        if context[\"suggestions\"]:\n            suggestions_count = context[\"suggestions\"].count()\n        context[\"suggestions_display\"] = formatter.number(suggestions_count)\n        context[\"language\"] = self.language\n        context[\"page\"] = \"admin-team\"\n        context[\"browse_url\"] = reverse(\n            \"pootle-language-browse\",\n            kwargs=dict(language_code=self.language.code))\n        context[\"translate_url\"] = reverse(\n            \"pootle-language-translate\",\n            kwargs=dict(language_code=self.language.code))\n        return context\n\n\nclass LanguageTeamAdminNewMembersJSON(PootleJSONMixin, PootleLanguageAdminFormView):\n    form_class = LanguageTeamNewMemberSearchForm\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            LanguageTeamAdminNewMembersJSON, self).get_context_data(**kwargs)\n        form = context[\"form\"]\n        return (\n            dict(items=form.search())\n            if form.is_valid()\n            else dict(items=[]))\n\n    def get_form_kwargs(self):\n        kwargs = super(LanguageTeamAdminNewMembersJSON, self).get_form_kwargs()\n        kwargs[\"data\"] = self.request.GET\n        return kwargs\n", "path": "pootle/apps/pootle_language/views.py"}]}