Skip to content

Commit

Permalink
Translation setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin Buczek committed May 5, 2019
1 parent cd6c253 commit 0f1c738
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions DEV_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Translation
In `urls.py`, `i18n_patterns()` can be passed `prefix_default_language=False`. This disables the language url prefix for the default language, but results in breaking Django's `set_language` view (used by language selection dropdown), as it is not able to get the current url without language prefix. This could be solved by passing the redirect location as POST parameter `next`, and would require to write a hacky solution to remove the language prefix, if it exists.
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
('en', _('English')),
('de', _('German')),
)
WAGTAILMODELTRANSLATION_TRANSLATE_SLUGS = False

# WAGTAIL
WAGTAIL_SITE_NAME = 'MPI CMS'
8 changes: 7 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.views import defaults as default_views


urlpatterns = [
path(settings.ADMIN_URL, admin.site.urls),
path('i18n/', include('django.conf.urls.i18n')),
re_path(r'^cms/', include(wagtailadmin_urls)),
re_path(r'^documents/', include(wagtaildocs_urls)),
re_path(r'', include(wagtail_urls)),
] + static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)

urlpatterns += i18n_patterns(
# These URLs will have /<language_code>/ appended to the beginning
re_path(r'', include(wagtail_urls)),
)

if settings.DEBUG:
urlpatterns += [
path(
Expand Down

0 comments on commit 0f1c738

Please sign in to comment.