Skip to content

Commit

Permalink
Revert "Add settings to control language prefix (wagtail#197)"
Browse files Browse the repository at this point in the history
This reverts commit a14be63.
  • Loading branch information
evyd13 committed May 22, 2021
1 parent dda2cb6 commit e7903e3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
2 changes: 0 additions & 2 deletions src/wagtailtrans/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
'SYNC_TREE': True,
'LANGUAGES_PER_SITE': False,
'HIDE_TRANSLATION_TREES': False,
'NO_PREFIX_FOR_DEFAULT_LANGUAGE': False,
'REDIRECT_UNPREFIXED_PATHS': False,
}


Expand Down
28 changes: 0 additions & 28 deletions src/wagtailtrans/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ def get_admin_display_title(self):
return "{} ({})".format(super().get_admin_display_title(), self.language)

def serve(self, request, *args, **kwargs):
if get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS'):
language = get_user_language(request)
if not request.path.startswith('/{}/'.format(language.code)):
if not get_wagtailtrans_setting('NO_PREFIX_FOR_DEFAULT_LANGUAGE') or not language.is_default:
return redirect(self.url)

activate(self.language.code)
return super().serve(request, *args, **kwargs)

Expand Down Expand Up @@ -362,29 +356,7 @@ def serve(self, request, *args, **kwargs):
except TranslatablePage.DoesNotExist:
raise Http404

def route(self, request, path_components):
path_components = self.prepend_language_code_to_path_components(request, path_components)
return super().route(request, path_components)

def prepend_language_code_to_path_components(self, request, path_components):
"""Prepend path_components with a language code if needed
:param request: Request object
:param path_components: List containing path elements
:return: List containing path elements
"""
if (
get_wagtailtrans_setting('NO_PREFIX_FOR_DEFAULT_LANGUAGE') or
get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS')
):
language = get_user_language(request)
if language.is_default or get_wagtailtrans_setting('REDIRECT_UNPREFIXED_PATHS'):
if path_components:
if language.code != path_components[0]:
path_components.insert(0, language.code)
else:
path_components = [language.code]
return path_components

def page_permissions_for_user(self, user):
"""Patch for the page permissions adding our custom proxy
Expand Down

0 comments on commit e7903e3

Please sign in to comment.