Closed auslaner closed 3 months ago
Is /admin/pages/1315/edit/
one of the translated pages?
The discrepancy between the number of source locale pages and translated pages is "interesting". Do you have anything else in the logs from when the rqworker ran?
If you run this locally with Debug = True, can you expand the error page context around
"source_translation": [
to see the value of props_translations
and perhaps translations
?
Also, what Wagtail and wagtail-localize versions are you on?
Yes, I think it is since it's within the tree hierarchy of the Spanish Locale.
The only notable log lines from the rqworker are two at the beginning:
rq.worker INFO default: wagtail_localize.synctree.synchronize_tree(<Locale: English>, <Locale: Spanish>, page_index=None) (bc2de079-6ab1-42c6-ab9c-1779efbf3e4b)
wagtail_localize.synctree WARNING 3 orphaned pages!
Otherwise, it it just a series of page and alias created messages with no other errors or warnings.
props_translations = [{'editUrl': '/admin/pages/161/edit/', 'locale': {'code': 'en', 'displayName': 'English'}, 'title': 'Employment'}]
translations = <PageQuerySet [<GeneralPage: Employment>]>
I am on Wagtail version 5.0.5 and wagtail_localize version 1.7.
hmm I take it translation.source.locale.language_code
is not 'en'.
Can you run the following in the Django shell?
from wagtail.models import Page
from wagtail_localize.models import Translation
page = Page.objects.get(pk=1315)
translation = Translation.objects.get(
source__object_id=page.translation_key,
target_locale_id=page.locale_id,
enabled=True,
)
print(translation.source.locale.language_code)
re: orphaned pages. python manage.py fixtree
should take care of that
Yeah, the above snippet gives me es
instead.
and page.locale.language_code
is es
too?
I just noticed you said "3. Choose "Translate Page" on one of the created Spanish Pages". Can you record a short screencast of the process with another page, if possible?
Yes it is!
>>> print(translation.source.locale.language_code)
es
>>> print(page.locale.language_code)
es
https://github.com/wagtail/wagtail-localize/assets/44983332/2615fbc4-5d9b-4e01-93c4-062c18d265e1
Hmm, could I be causing an issue by having English as en-us
in LANGUAGE_CODE = 'en-us'
but just en
in here:
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
('en', 'English'),
('es', 'Spanish'),
('zh', 'Chinese'),
]
Edit: To answer my own question, no, that does not seem to make a difference. I see the same behavior with LANGUAGE_CODE set to en
to match the others and confirmed that the language code of the English Locale object was set to en
as well.
I have noticed the Locale '{0}' created
too.
This can be fixed by defining success_message
as a property function, instead of an attribute on the class - and properly formatting it.
The issue is with the following classes in wagtail_localize.locales.views
:
class CreateView(...)
class EditView(...)
class DeleteView(...)
Let's split the success message to a separate issue - #761
@auslaner it is possible there is an issue with the discrepancy. Will try to test that on a fresh install over the weekend
This is probably the same as #774 (so #775 should fix it) - although existing data might need to be fixed/removed manually.
@auslaner can check whether you get the same behaviour with wagtail-localize 1.9?
It does seem to be solved!
My test is not a perfect recreation of the original issue since I'm now using Django 4.2.13 and wagtail 5.2.5 but I was able to successfully install wagtail-localize 1.9, create a locale, and then translate a page from that locale without hitting any errors so I'd say this issue is safe to close!
I am getting the following error when trying to translate a page just after creating a new Locale via the admin interface:
My steps to reproduce are:
Some potentially related oddities I'm seeing are that when creating the Locale, the Django success message says
Locale '{0}' created.
. Also, from the top level view of the Locales, the newly created Locale will list a usage of 527 pages when the source Locale is 763 Pages.