diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index 696e6d8fbe7..20766f781fb 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -179,18 +179,19 @@ def clean_language(self): language = self.cleaned_data['language'] project = self.instance if project: + msg = _( + 'There is already a "{lang}" translation ' + 'for the {proj} project.' + ) + format_msg = msg.format(lang=language, proj=project.slug) if project.translations.filter(language=language).exists(): - msg = 'There is a translation for the "{lang}" language.' - raise forms.ValidationError( - _(msg).format(lang=language) - ) + raise forms.ValidationError(format_msg) main_project = project.main_language_project - if main_project and main_project.language == language: - msg = ( - 'The translation can not have the same ' - 'language as the parent.' - ) - raise forms.ValidationError(_(msg)) + if main_project: + if main_project.language == language: + raise forms.ValidationError(format_msg) + if main_project.translations.filter(language=language).exists(): + raise forms.ValidationError(format_msg) return language