Package: collatinus
Version: 12.3-2
Severity: normal
Tags: patch upstream

Setting the interface language to English has no effect. The menus stay French
in every session, although collatinus_en.qm ships with the package and the
setting is stored correctly as langue=en in
~/.config/Collatinus/collatinus12.conf.

Two separate defects cause this, and fixing either one alone changes nothing.

First, setLangue() in src/mainwindow.cpp builds the path to the translation by
hand, from the directory of the executable:

    translator->load(qApp->applicationDirPath() + "/data/collatinus_"
+ langueI);

On a packaged install that resolves to /usr/bin/data/, which does not exist:

    access("/usr/bin/data/collatinus_en.qm", R_OK) = -1 ENOENT

Every other resource is found through Ch::chemin(), which falls back to
QStandardPaths and locates /usr/share/collatinus/data. That is why lexicons,
dictionaries and inflection tables work while the translation never loads.

Second, setLangue() is the last statement of the MainWindow constructor, after
createActions(), createMenus() and createToolBars() have already built the
interface. Qt substitutes translations when tr() runs, and nothing calls
retranslateUi() afterwards, so the widgets keep the French strings they were
created with. This also explains the dialog that promises the change will take
effect at the next launch: the next launch repeats the same order, so the
promise is never kept.

I verified both halves before writing the patch. With the path corrected, the
.qm file is opened and then ignored; with the call order corrected, there is
still nothing to open.

How to reproduce, on a package from the archive:

1. Start collatinus, choose View > English Interface, confirm the dialog.
2. Quit, so that the setting is written, and start it again.
3. The menus are still French. `strace -e trace=%file` shows the ENOENT above.

The attached patch uses Ch::chemin() for the translation, the same helper the
other resources use, and moves setLangue() to the start of the constructor,
before any widget exists. I built 12.2-1ubuntu2 with it on Ubuntu 24.04 and the
interface comes up in English, with the lexicon and scansion working as before.

The code is identical in Debian 12.3-2 and in both upstream branches, master
and c12: same call at line 218, same load at line 2249. Upstream has had no
code changes since 2021, so the fix is unlikely to arrive from there.
Description: Load the interface translation, and load it in time
 Two independent defects keep the English interface from ever appearing,
 even though collatinus_en.qm ships with the package and the setting
 [interface] langue=en is read correctly.
 .
 1. setLangue() builds the path to the .qm file by hand, from the directory
    of the executable. On an FHS install that is /usr/bin/data/, which does
    not exist:
        access("/usr/bin/data/collatinus_en.qm", R_OK) = -1 ENOENT
    Every other resource is located through Ch::chemin(), which falls back
    to QStandardPaths and finds /usr/share/collatinus/data — that is why
    lexicons and dictionaries work while the translation does not.
 .
 2. setLangue() is the last statement of the MainWindow constructor, long
    after createActions(), createMenus() and createToolBars() have built the
    interface. Qt substitutes translations when tr() runs, and nothing calls
    retranslateUi() afterwards, so the menus keep their French strings. This
    is also why the dialog promising the change "will take effect at the next
    launch" never comes true: the next launch repeats the same order.
 .
 Fixing either defect alone changes nothing: with the path corrected the .qm
 file is opened and then ignored; with the order corrected there is still no
 file to load. Both branches upstream (master, c12) carry the same code.
Forwarded: no
Last-Update: 2026-08-29
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -170,6 +170,10 @@
     QString style(styleFile.readAll());
     qApp->setStyleSheet(style);
 
+    // Avant toute creation de widget : QTranslator n'agit qu'au moment ou
+    // tr() est appele, et rien ne retraduit l'interface apres coup.
+    setLangue();
+
     editLatin = new EditLatin(this);
     setCentralWidget(editLatin);
 
@@ -214,8 +218,6 @@
     lasla = new Lasla(this,lemcore,"");
     tagueur = new Tagueur(this,lemcore);
     scandeur = new Scandeur(this,lemcore);
-
-    setLangue();
 }
 
 /**
@@ -2246,7 +2248,11 @@
     if (!langueI.isEmpty())
     {
         translator = new QTranslator(qApp);
-        translator->load(qApp->applicationDirPath() + "/data/collatinus_" + langueI);
+        // Meme recherche que pour les autres ressources : a cote de
+        // l'executable si data/ s'y trouve, sinon /usr/share/collatinus/data.
+        QString dirLangues = Ch::chemin("collatinus/data", 'd');
+        if (!dirLangues.endsWith('/')) dirLangues.append('/');
+        translator->load(dirLangues + "collatinus_" + langueI);
         qApp->installTranslator(translator);
     }
     else

Reply via email to