wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

PO file translations - MultipleObjectsReturned error #600

Closed byandrej closed 2 years ago

byandrej commented 2 years ago

I was trying to translate a page using PO editor. But I got error: get() returned more than one String -- it returned 2! An error was made by one of query selector in wagtail_localize/models.py:

    for index, entry in enumerate(po):
        try:
            string = String.objects.get( …
                locale_id=self.source.locale_id, data=entry.msgid
            )
           ...

with kwargs {'data': 'Lokacija', 'locale_id': 1}, clone:<QuerySet [<String: String object (662)>, <String: String object (663)>

In wagtail_localize_string there were two strings with the same name but one started with a capital letter and the other with a small letter (One is probably title and the other is slug). In DB I found 10 duplicated strings, all of them with same situation.

Modify | id | data_hash | data | locale_id -- | -- | -- | -- | -- uredi | 662 | 331eb28504df5b48966cf4b1ec541ba8 | Lokacija | 1 uredi | 663 | 8d7c8d74ab4f5957ab6a9670d04e6b7c | lokacija | 1

Any idea how to solve this?

Django Version: 4.0.6 Python Version: 3.10.4 Wagtail: 2.16.2 wagtail-localize: 1.2.1

zerolab commented 2 years ago

Related discussion: https://github.com/wagtail/wagtail-localize/discussions/606