Repository: cal-itp/benefits

Issue:
Bug: Spanish translations on all error pages are not showing up.
## To Reproduce

Steps to reproduce the behavior:

1. Go to benefits.calitp.org/
2. Click on Spanish
3. Go to benefits.calitp.org/asfakljsfasdf
4. See error

<img width="705" alt="image" src="https://user-images.githubusercontent.com/3673236/190244616-0867bdbe-cd77-477f-9fd0-0cf8f3b8625a.png">

Happening for 404 and 500

## Expected behavior

All the text should be in Spanish, not just the Footer and the Button.

## Screenshots

<img width="705" alt="image" src="https://user-images.githubusercontent.com/3673236/190244616-0867bdbe-cd77-477f-9fd0-0cf8f3b8625a.png">

## Desktop (please complete the following information)

Both 

## Smartphone (please complete the following information)

All

## Additional context

Fix translations on error pages (default arguments set once, need to use None and check for None instead)




Discussion:

Resolving patch:
diff --git a/benefits/core/viewmodels.py b/benefits/core/viewmodels.py
--- a/benefits/core/viewmodels.py
+++ b/benefits/core/viewmodels.py
@@ -1,7 +1,7 @@
 """
 The core application: view model definitions for the root of the webapp.
 """
-from django.utils.translation import pgettext, gettext as _
+from django.utils.translation import pgettext, gettext_lazy as _
 from django.urls import reverse
 
 from benefits.core import models


Test patch:
diff --git a/tests/pytest/core/test_viewmodels.py b/tests/pytest/core/test_viewmodels.py
new file mode 100644
--- /dev/null
+++ b/tests/pytest/core/test_viewmodels.py
@@ -0,0 +1,60 @@
+from django.utils import translation
+from django.utils.translation import gettext as _
+
+from benefits.core.viewmodels import ErrorPage
+
+
+def test_ErrorPage_error_translations():
+    translation.activate("en")
+
+    error_page = ErrorPage.error()
+    english_title = f"{_('core.pages.index.prefix')}: {_('core.pages.server_error.title')}"
+    english_content_title = _("core.pages.server_error.title")
+    english_paragraphs = [_("core.pages.server_error.p[0]"), _("core.pages.server_error.p[1]")]
+
+    assert error_page.title == english_title
+    assert error_page.content_title == english_content_title
+    assert error_page.paragraphs == english_paragraphs
+
+    translation.activate("es")
+
+    error_page = ErrorPage.error()
+    spanish_title = f"{_('core.pages.index.prefix')}: {_('core.pages.server_error.title')}"
+    spanish_content_title = _("core.pages.server_error.title")
+    spanish_paragraphs = [_("core.pages.server_error.p[0]"), _("core.pages.server_error.p[1]")]
+
+    assert error_page.title != english_title
+    assert error_page.content_title != english_content_title
+    assert error_page.paragraphs != english_paragraphs
+
+    assert error_page.title == spanish_title
+    assert error_page.content_title == spanish_content_title
+    assert error_page.paragraphs == spanish_paragraphs
+
+
+def test_ErrorPage_not_found_translations():
+    translation.activate("en")
+
+    error_page = ErrorPage.not_found()
+    english_title = f"{_('core.pages.index.prefix')}: {_('core.pages.not_found.title')}"
+    english_content_title = _("core.pages.not_found.content_title")
+    english_paragraphs = [_("core.pages.not_found.p[0]")]
+
+    assert error_page.title == english_title
+    assert error_page.content_title == english_content_title
+    assert error_page.paragraphs == english_paragraphs
+
+    translation.activate("es")
+
+    error_page = ErrorPage.not_found()
+    spanish_title = f"{_('core.pages.index.prefix')}: {_('core.pages.not_found.title')}"
+    spanish_content_title = _("core.pages.not_found.content_title")
+    spanish_paragraphs = [_("core.pages.not_found.p[0]")]
+
+    assert error_page.title != english_title
+    assert error_page.content_title != english_content_title
+    assert error_page.paragraphs != english_paragraphs
+
+    assert error_page.title == spanish_title
+    assert error_page.content_title == spanish_content_title
+    assert error_page.paragraphs == spanish_paragraphs