puput icon indicating copy to clipboard operation
puput copied to clipboard

i18n support

Open nux17 opened this issue 8 years ago • 10 comments

Hi, how i18n is handled in pupput?

My blog has to be both in english and french. Is there a way to add a blog entry in 2 languages?

Thanks.

nux17 avatar Sep 03 '16 14:09 nux17

Hi @nux17, We are writing a documentation with the approach that we developed for our customers. The main idea is that you have to duplicate your content for each language. Since Wagtail doesn't have a proper i18n support we need to do tweaks like this in order figure out this problem.

marctc avatar Sep 05 '16 09:09 marctc

Sure, so are the translation features available right now?

nux17 avatar Sep 05 '16 12:09 nux17

As I said, you have to duplicate your content. So you need to create a structure like /en/blog/ and /fr/blog and create the same entries for each blog.

marctc avatar Sep 05 '16 12:09 marctc

Got it. So no i18n support on url patterns for the blog. That's weird Wagtail doesn't support localization OOB.

nux17 avatar Sep 05 '16 12:09 nux17

Could I have some support doing this?

I need it translated in French and English, do I have to insert puppet urls inside i18n patterns and then build 2 sites on Wagtail admin? Just need some advices doing it the proper way.

Is that what is reffering this Wagtail doc page to?

@marctc Thanks for helping.

nux17 avatar Sep 05 '16 15:09 nux17

Hi @nux17 ! Yes, we are talking about the refered Wagtail doc page. You don't have to insert puput urls inside i18n because the language code in the url will be the title/slug of your "home pages" at the Wagtaild admin. You just need to follow the puput's documentation.

Puput's now ready to suport this, @marctc and I work on it in this commit and this other one. The idea of this issue can be find at the first commit, at the second there are some fixes.

That's what I've done and, if you link your pages, it works properly.

I'll add a section to the Puput's documentation explaining this issue. I'll try to do it in short time. Meanwhile, I hope that this short comment will be useful.

csalom avatar Sep 05 '16 20:09 csalom

Thanks for helping @csalom!

Almost got this to work. Here are my urls: `urlpatterns = i18n_patterns( url(r'^$', index), )

urlpatterns += [ url(r'^admin/', admin.site.urls), url(r'^newsletter', newsletter_handler), url(r'^robots.txt$', lambda r: HttpResponse("User-agent: *\nDisallow:")),]

urlpatterns += url(r'^language/', include('django.conf.urls.i18n')),

urlpatterns += url(r'', include('puput.urls')), `

Going to /blog works and redirects me on the right Blog depending on language.

Since my root page isn't a Wagtail one but a static view with i18n patterns, going to / should redirect me to /fr or /en, but puput_initial_data links this to a root page and just shows me a blank page with Root written on.

Without that page, i18n patterns add an /en before /blog and thus the route isn't done the good way and my blog is not reachable.

How to merge those routes and to work?

I guess there's an issue about using a static page at r'' and puput routes...

nux17 avatar Sep 07 '16 12:09 nux17

Hi @nux17, As you said, that solution is not good enough. It's not completed. As I tried to explain at my other comment, you have to include a new page above the blog's page. When you look at your wagtail tree (at the admin) instead of /blog/ at your root level you should see: /fr/blog and /en/blog.

You have to follow wagtail's documentation at this link. Try to understand the first example. It's very similar to the wagtail tree that you must have to be able to run what you want correctly. You should place your blogs at the same level of the contact pages.

See you, Carlos.

csalom avatar Sep 12 '16 20:09 csalom

Hello all, Is there an easy way to integrate wagtailtrans with puput? Many thanks.

ahwebd avatar Dec 10 '18 13:12 ahwebd

Tried the following and it seems working fine:

  1. Created an abstract class from "TranslatablePage":
from wagtailtrans.models import TranslatablePage
class TranslatablePageAbstract(TranslatablePage):
    class Meta:
        abstract = True
  1. Subclassed from the previous class and puput pages.
from puput.models import BlogPage, EntryPage
from wagtailtrans.models import TranslatablePage

class TranslatablePageAbstract(TranslatablePage):
    class Meta:
        abstract = True

class TranslatableBlogPage(TranslatablePageAbstract, BlogPage):
    subpage_types = ['blog.TranslatableEntryPage']

class TranslatableEntryPage(TranslatablePageAbstract, EntryPage):
    parent_page_types = ['blog.TranslatableBlogPage']

Any thoughts about this implementation? Any issues that might arise?

If all is fine with this method I suggest adding it to the docs.

ahwebd avatar Dec 16 '18 15:12 ahwebd

I'll close this issue because Internationalisation is included on the wagtail versions supported by Puput.

csalom avatar May 25 '23 07:05 csalom