Add a language argument to LocalizedValue.translate(..)

This commit is contained in:
Swen Kooij
2019-10-20 16:49:33 +03:00
parent e5dcc1b492
commit 7bf0311306
2 changed files with 35 additions and 8 deletions

View File

@@ -172,6 +172,18 @@ class LocalizedValueTestCase(TestCase):
with translation.override("nl"):
assert localized_value.translate() == "ro"
@staticmethod
def test_translate_custom_language():
"""Tests whether the :see:LocalizedValue class's translate() ignores
the active language when one is specified explicitely."""
localized_value = LocalizedValue(
{settings.LANGUAGE_CODE: settings.LANGUAGE_CODE, "ro": "ro"}
)
with translation.override("en"):
assert localized_value.translate("ro") == "ro"
@staticmethod
def test_deconstruct():
"""Tests whether the :see:LocalizedValue class's :see:deconstruct