Skip to content

Commit

Permalink
TranslationModelFrom: change default languages to include fallback (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvdp authored Jun 29, 2021
1 parent 4aa5d12 commit 7e8b1de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/pages/translation-model-form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Setting the form languages
- `"browser"`: the language that is active in the browser session
- `"fallback"`: the fallback language either defined in the form, the model instance, or in the system, in that order of priority
- a language code: e.g. `"fr"`, `"it"`
- Default: `["browser", "fallback"]`
- Ordering: the ordering defined in the declaration is preserved
- Duplicate languages are removed, e.g. `["browser", "fr", "fallback"]`, becomes `["fr"]` if browser language and fallback are also `"fr"`.

Expand Down
2 changes: 1 addition & 1 deletion modeltrans/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TranslationModelFormOptions(forms.models.ModelFormOptions):

def __init__(self, options=None):
super().__init__(options)
self.languages = getattr(options, "languages", ["browser"])
self.languages = getattr(options, "languages", ["browser", "fallback"])
self.fallback_language = getattr(options, "fallback_language", None)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Meta:
def test_defaults(self):
"""Test the default form options."""
form = Form()
self.assertEqual(form.languages, ["browser"])
self.assertEqual(form.languages, ["browser", "fallback"])
self.assertEqual(form.fallback_language, get_default_language())

def test_get_fallback_language(self):
Expand Down

0 comments on commit 7e8b1de

Please sign in to comment.