Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translating wagtailimages.Image #174

Open
jorenham opened this issue Feb 16, 2018 · 9 comments
Open

translating wagtailimages.Image #174

jorenham opened this issue Feb 16, 2018 · 9 comments

Comments

@jorenham
Copy link
Contributor

jorenham commented Feb 16, 2018

I have my translation.py setup like this:

from wagtail.wagtailimages.models import Image
from wagtail_modeltranslation.translation import TranslationOptions as WagtailTranslationOptions

@register(Image)
class WagtailImageTranslationOptions(WagtailTranslationOptions):
    fields = ('title', )

However when running makemigrations and migrate nothing happens and Django starts complaining: no such column: wagtailimages_image.title_nl

I have added 'wagtail_modeltranslation.makemigrations' to my INSTALLED_APPS.

Am I missing something?

@dmarcelino
Copy link
Collaborator

Hi @jorenham,

Which version of wagtail-modeltranslation are you using?
I suggest you use the latest - v0.8 and please note that WagtailTranslationOptions were removed in v0.8, refer to Quick Start on how to replace it.

Lastly, note that translating one of Wagtail's own model will result in a Wagtail migration or you'll need to use django-modeltranslation's sync_translation_fields. Please read django-modeltranslation's Committing fields to database so you understand the implications.

If possible I suggest you subclass Image and translate the child class.

@jorenham
Copy link
Contributor Author

jorenham commented Feb 16, 2018

@dmarcelino I'm currently on 0.8.
The WagtailTranslationOptions is an import rename of WagtailTranslationOptions (see updated issue).

sync_translation_fields created the appropriate fields. But in the Wagtail UI the translations cannot be entered for the image title.

@dmarcelino
Copy link
Collaborator

Cool!

@jorenham
Copy link
Contributor Author

@dmarcelino Oh sorry I updated the answer, it was not resolved after all.

@dmarcelino
Copy link
Collaborator

But in the Wagtail UI the translations cannot be entered for the image title.

Can you please expand on this or send a screenshot?

@dmarcelino dmarcelino reopened this Feb 16, 2018
@jorenham
Copy link
Contributor Author

@dmarcelino In the wagtail edit page of an Image (e.g. localhost:8000/wagtailadmin/images/42/), I'd expect there to be several title input fields for each language. However, it appears that nothing has changed and there still is only one title input field.

@dmarcelino
Copy link
Collaborator

I see now, sounds like something is not working properly when patching the Image Panel. I haven't done much work in that area unfortunately. @DiogoMarques29, any thoughts?

@DiogoMarques29
Copy link
Collaborator

Hello @jorenham and @dmarcelino
At this point, we are only patching the edit Page interface.
makemigrations and migrate commands will create the translated fields if you register the Image model for translation, but there are 2 problems: the migration will be created in wagtailimage app; the edit interface for images is not patched, so the translated fields will not be shown.

Alternatively, you can register the FK field to image in your page and that will work. The downside is that you have to replicate the image model for each language you have installed.

@jorenham
Copy link
Contributor Author

Any plans on implementing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants