wagtail / wagtailtrans

A Wagtail add-on for supporting multilingual sites
http://wagtailtrans.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
104 stars 60 forks source link

what the differences with wagtail doc "Creating sites with multiple languages" #166

Closed scil closed 4 years ago

scil commented 5 years ago

In the doc, there are Serving different languages from different URLs and and "Duplicating the fields in your model".

So does wagtailtrans work together with these codes?

# mysite/urls.py

from django.conf.urls import include, re_path
from django.conf.urls.i18n import i18n_patterns
from django.conf import settings
from django.contrib import admin

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.core import urls as wagtail_urls
from search import views as search_views

urlpatterns = [
    re_path(r'^django-admin/', include(admin.site.urls)),

    re_path(r'^admin/', include(wagtailadmin_urls)),
    re_path(r'^documents/', include(wagtaildocs_urls)),
]

urlpatterns += i18n_patterns(
    # These URLs will have /<language_code>/ appended to the beginning

    re_path(r'^search/$', search_views.search, name='search'),

    re_path(r'', include(wagtail_urls)),
)
class BlogPage(Page):

    title_fr = models.CharField(max_length=255)

    body_en = StreamField(...)
    body_fr = StreamField(...)

    # Language-independent fields don't need to be duplicated
    thumbnail_image = models.ForeignKey('wagtailimages.Image', on_delete=models.SET_NULL, null=True, ...)
jjanssen commented 4 years ago

Hi @scil,

Sorry for the delay in the answer.

In short: I would not recommend it to use with Wagtailtrans as it would be confusing and (for example) Wagtailtrans is not supporting i18n_patterns just yet (#88)

The code you're referring to from the Wagtail documentation, is another approach to handling internationalisation by setting the fields on the Page model. Which is a fine solution if the amount of languages you are supporting is manageable. Just keep in mind when adding languages, you will also need to create a new database migration.

Wagtailtrans takes a different approach in having internationalisation becoming a bit more user-friendly for the editor when supporting a fair amount of languages. Where with Wagtailtrans it does not require a new database migration when adding a new language. But it is just another approach as there is no "one-size-fits-all"-solution on how internationalisation fits into your organisation or your clients. We explained a bit in our documentation, but I realise we could have explained this part a bit better.

Another option for internationalisation could be wagtail-localize which is briefly explained in the Torchbox Blog's.