SUMMARY Typically the Alternative Translations window shows 1 or sometimes 2 entries. When the entry shown is from the alternative translation file (e.g. a different language entry to the current translation language), the option to enter the ATM entry text is shown as Alt+1 etc. but sometimes the CatalogStorage m_storage provided by catalog.h has an entry already and then in catalop.cpp Catalog::altTrans() a seemingly identical entry is added. This is happening with .po files, and causes the entry in the ATM to display with the keyboard shortcut Alt+2 even though it's the first entry, because the shortcut number is generated based on the current loop in alttransview.cpp AltTransView::process() and the first entry was skipped. STEPS TO REPRODUCE 1. Set up alternative translations file in project settings. 2. Open a file with related entries from the alternative translations file.
This also causes problems for the alttransview.cpp AltTransView::process() logic, not just for displaying entries, because the function should exit early if there are no entries. The empty initial entry is added to m_storage in catalog.cpp Catalog::altTrans() because that function returns a QVector<AltTrans>, and the first entry (typically? always?) has empty source and target strings because of this code, where the altTrans() contains an entry that has empty source and target strings: if (m_storage) result = m_storage->altTrans(pos);
A possibly relevant merge request was started @ https://invent.kde.org/sdk/lokalize/-/merge_requests/192
Git commit 64903c06c65e8bbdd9a27ea50ba03c1c5183b731 by Finley Watson. Committed on 28/12/2024 at 14:21. Pushed by jjazeix into branch 'master'. Do not return QVector with an empty AltTrans Only return a QVector containing data when data actually exists for at least one field of the AltTrans struct. M +6 -3 src/catalog/gettext/gettextstorage.cpp https://invent.kde.org/sdk/lokalize/-/commit/64903c06c65e8bbdd9a27ea50ba03c1c5183b731
Git commit b79e41273df1360bb11fa94dc953c6cf8b25bbff by Albert Astals Cid, on behalf of Finley Watson. Committed on 02/01/2025 at 22:58. Pushed by aacid into branch 'release/24.12'. Do not return QVector with an empty AltTrans Only return a QVector containing data when data actually exists for at least one field of the AltTrans struct. (cherry picked from commit 64903c06c65e8bbdd9a27ea50ba03c1c5183b731) M +6 -3 src/catalog/gettext/gettextstorage.cpp https://invent.kde.org/sdk/lokalize/-/commit/b79e41273df1360bb11fa94dc953c6cf8b25bbff