Repository: wagtail/wagtail
File: wagtail/locales/views.py (Python)

Code before:
from wagtail.models import Locale
from wagtail.permissions import locale_permission_policy

from .forms import LocaleForm
from .utils import get_locale_usage

if TYPE_CHECKING:
    from django.http import HttpRequest, HttpResponseBase


class LanguageTitleColumn(TitleColumn):
    cell_template_name = "wagtaillocales/_language_title_cell.html"

    def get_value(self, locale):
        return locale


def _can_add_locale() -> bool:
    defined_locales = [
        language[0]
        # WAGTAIL_CONTENT_LANGUAGES is a list of tuples (language_code, language)
        for language in getattr(settings, "WAGTAIL_CONTENT_LANGUAGES", [])
    ]
    return Locale.objects.filter(language_code__in=defined_locales) < len(
        defined_locales
    )


class LocaleUsageColumn(Column):
    def get_value(self, locale):
        num_pages, num_others = get_locale_usage(locale)
        if num_others:
            return gettext_lazy("%(num_pages)d pages and %(num_others)d others") % {
                "num_pages": num_pages,
                "num_others": num_others,
            }

        return ngettext_lazy("%(num_pages)d page", "%(num_pages)d pages", num_pages) % {
            "num_pages": num_pages
        }


class IndexView(generic.IndexView):
    page_title = gettext_lazy("Locales")
    add_item_label = gettext_lazy("Add a locale")
    context_object_name = "locales"
    queryset = Locale.all_objects.all()
    default_ordering = "language_code"

    columns = [
        LanguageTitleColumn(

Review comment (suggestion):
Missing `.count()`:

```suggestion
    return Locale.objects.filter(language_code__in=defined_locales).count() < len(
        defined_locales
    )
```

Code after:
from wagtail.models import Locale
from wagtail.permissions import locale_permission_policy

from .forms import LocaleForm
from .utils import get_locale_usage

if TYPE_CHECKING:
    from django.http import HttpRequest, HttpResponseBase


class LanguageTitleColumn(TitleColumn):
    cell_template_name = "wagtaillocales/_language_title_cell.html"

    def get_value(self, locale):
        return locale


def _can_add_locale() -> bool:
    content_languages = get_content_languages().keys()
    created_locales = Locale.objects.filter(language_code__in=content_languages)
    return created_locales.count() < len(content_languages)


class LocaleUsageColumn(Column):
    def get_value(self, locale):
        num_pages, num_others = get_locale_usage(locale)
        if num_others:
            return gettext_lazy("%(num_pages)d pages and %(num_others)d others") % {
                "num_pages": num_pages,
                "num_others": num_others,
            }

        return ngettext_lazy("%(num_pages)d page", "%(num_pages)d pages", num_pages) % {
            "num_pages": num_pages
        }


class IndexView(generic.IndexView):
    page_title = gettext_lazy("Locales")
    add_item_label = gettext_lazy("Add a locale")
    context_object_name = "locales"
    queryset = Locale.all_objects.all()
    default_ordering = "language_code"

    columns = [
        LanguageTitleColumn(
            "language",
            label=gettext_lazy("Language"),
            sort_key="language_code",
            url_name="wagtaillocales:edit",
        ),