Open rafrasenberg opened 5 years ago
Hi @webconexus ,
Django translations should work with WagtailTrans.
Did you follow the WagtailTrans documentation? this sounds like u need to add the wagtailtrans.middleware.TranslationMiddleware
to your middleware classes.
Docs
If that's not the case can you please add your configuration in this request?
Kind regards
@Henk-JanVanHasselaar Yes I followed the docs, to be clear Wagtailtrans is working completely fine. It is just the Django strings that don't get rendered.
So my setup: beautifulsoup4==4.6.0 certifi==2018.11.29 chardet==3.0.4 Django==2.1.7 django-appconf==1.0.2 django-compressor==2.2 django-environ==0.4.5 django-filter==2.1.0 django-livereload-server==0.3.2 django-modelcluster==4.3 django-sass-processor==0.7.2 django-shortcuts==1.6 django-taggit==0.23.0 django-treebeard==4.3 djangorestframework==3.9.1 draftjs-exporter==2.1.5 html5lib==1.0.1 idna==2.8 libsass==0.17.0 Pillow==5.4.1 pytz==2018.9 rcssmin==1.0.6 requests==2.21.0 rjsmin==1.0.12 six==1.12.0 tornado==5.1.1 Unidecode==1.0.23 urllib3==1.24.1 wagtail==2.4 wagtail-metadata==2.0.1 wagtailtrans==2.0.5 webencodings==0.5.1 Willow==1.1
Added this to my middleware:
'wagtailtrans.middleware.TranslationMiddleware',
Other settings:
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
So the strings are being picked up and I can see them in my .po file, it is just the rendering that does not work.
Allright, looks good so far! what does your middleware configuration look like?
Cool! Full middleware:
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
'wagtailtrans.middleware.TranslationMiddleware',
'livereload.middleware.LiveReloadScript',
]
Oke, just to be sure, can you order the middleware to match the order specified in the documentation. e.g:
MIDDLEWARE_CLASSES = [
# ...
'django.contrib.sessions.middleware.SessionMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtailtrans.middleware.TranslationMiddleware',
'django.middleware.common.CommonMiddleware',
# ...
]
further checks you can do,
TranslatableSiteRootPage
Hello,
I am wondering how to use the Django string translation in combination with Wagtailtrans. I tried my luck on stackoverflow but nobody awnsered it. Here's my question (short version without explaining what wagtailtrans is):
I translated my content, all is working fine, however I still need some additional strings which I don't define in my models to be translated. I just use Django's translation feature with
{% load i18n %}
and then the strings wrapped inside{% trans "String" %}
.So far so good, I defined my two languages in Wagtail admin (Wagtail trans creates an option for that) which in this case is English and Dutch. I set English as the main language so the strings are in english.
I use
./manage.py makemessages
and it creates a .po file for me, with all the tagged strings in there. At last I use./manage.py compilemessages.
But translated strings are not showing up when I switch to Dutch language, it still displays the english strings. So I suspect it needs some additional tweaking to work with Wagtailtrans, but I can't seem to figure out how this set-up should be. Can anyone help me out?
The link to the question on stackoverflow: https://stackoverflow.com/questions/54854263/how-can-i-use-djangos-translation-strings-with-wagtailtrans-add-on-for-support