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

some QDialogButtonBox items are not translated in any language #1224

Closed
fedelibre opened this issue Dec 18, 2019 · 24 comments
Closed

some QDialogButtonBox items are not translated in any language #1224

fedelibre opened this issue Dec 18, 2019 · 24 comments

Comments

@fedelibre
Copy link
Member

I've updated the italian translation and noticed that some items in the File menu are not translated, because the string is not extracted in the PO file.
Here's an example:

$ git grep -w 'New Document' frescobaldi_app/
...
frescobaldi_app/mainwindow.py:        self.file_new.setText(_("action: new document", "&New Document"))
frescobaldi_app/preferences/general.py:        self.tabs.setTabText(0, _("New Document"))

Only the second instance in preferences/ is present in the PO files, while the first is missing:

$ git grep '&New' i18n/it/frescobaldi.po
i18n/it/frescobaldi.po:msgid "&New"
i18n/it/frescobaldi.po:msgid "Open Link in &New Window"
i18n/it/frescobaldi.po:msgid "Open Document in &New Window"
i18n/it/frescobaldi.po:msgid "&New..."
i18n/it/frescobaldi.po:msgid "&New Folder"
[fede@localhost frescobaldi]$ git grep '&New' i18n/fr/frescobaldi.po
i18n/fr/frescobaldi.po:msgid "&New"
i18n/fr/frescobaldi.po:msgid "Open Link in &New Window"
i18n/fr/frescobaldi.po:msgid "Open Document in &New Window"
i18n/fr/frescobaldi.po:msgid "&New..."
i18n/fr/frescobaldi.po:msgid "&New Folder"
i18n/fr/frescobaldi.po:#~ msgid "&New..."
[fede@localhost frescobaldi]$ git grep '&New' i18n/es/frescobaldi.po
i18n/es/frescobaldi.po:msgid "&New"
i18n/es/frescobaldi.po:msgid "Open Link in &New Window"
i18n/es/frescobaldi.po:msgid "Open Document in &New Window"
i18n/es/frescobaldi.po:msgid "&New..."
i18n/es/frescobaldi.po:msgid "&New Folder"

The other missing strings of File menu are: New, Close Document, Close, Save Document, Save.

Another example:

$ git grep -w 'Close Document' frescobaldi_app/
frescobaldi_app/mainwindow.py:            res = QMessageBox.warning(self, _("dialog title", "Close Document"),
frescobaldi_app/mainwindow.py:        self.file_close.setText(_("&Close Document"))
[fede@localhost frescobaldi]$ 
[fede@localhost frescobaldi]$ git grep -B2 -w 'Close Document' i18n/it/frescobaldi.po
i18n/it/frescobaldi.po-#: ../../frescobaldi_app/mainwindow.py:350
i18n/it/frescobaldi.po-msgctxt "dialog title"
i18n/it/frescobaldi.po:msgid "Close Document"
@fedelibre
Copy link
Member Author

Other untranslated items:

  • the Help, Close, Reset, Restore Defaults buttons in the dialogs
  • the Apply button in the Preferences
  • Magnifier Size in frescobaldi_app/preferences/musicviewers.py:117

@uliska
Copy link
Collaborator

uliska commented Dec 18, 2019

Just to be sure: You did run update-pot.py (because “This script must be run if new translatable strings are added to Frescobaldi.“)?

@fedelibre
Copy link
Member Author

Yes, I ran Make, which then runs update-pot.py

It is up-to-date. In i18n/:

$ make it/frescobaldi.po 
make: 'it/frescobaldi.po' is up to date.

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 18, 2019

make pot updates the pot file, I just did it!

@fedelibre
Copy link
Member Author

Oh, you are right. I'll close this issue.

Even if I wonder if this could be handled better by the Makefile.. for example, adding pot as a dependency of mo target.

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 19, 2019

That could be done, but then would the pot files need to depend on all the source files, and that would retrigger an update on every change to a source file, even if no strings were added or changed.

@fedelibre
Copy link
Member Author

I see.. but it seems a necessary step to get a PO file matching the status of the application, IIUC.

I've updated the po file using a self-updated pot but I still get the untranslated strings. Why?

I see that setup.py installs two .mo files in different directories. Is it correct?

 grep 'it.mo' installed-files.txt 
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/po/it.mo
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/i18n/it.mo

diff says that the two binary files differ.
I can't remember now how to see the differences in the binaries...

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 19, 2019

The po folder has been removed, so that's probably a remnant from a previous installation.

@fedelibre
Copy link
Member Author

Not exactly, as I've cleared the previous installation.
Perhaps some old pyc file in the source tree is interfering?

I tried this command in frescobaldi repository:

rm -rf frescobaldi_app/po

but again the list of installed files generated by --record includes two it.mo files:

$ python3 setup.py install --prefix ~/.local --record installed-files.txt
$ grep 'it.mo' installed-files.txt 
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/po/it.mo
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/i18n/it.mo

@fedelibre
Copy link
Member Author

And if I clone the repository from scratch and install using setuptools in the same way, this time I do not get any translation.
Can you please test an installation using a clean repository?

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 19, 2019

Because the mo files are not in git, you must create them using make -C i18n.

The mo files are in the release tarball (I'd like to need no build phase in the release tarball).

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 19, 2019

Not exactly, as I've cleared the previous installation.
Perhaps some old pyc file in the source tree is interfering?

I tried this command in frescobaldi repository:

rm -rf frescobaldi_app/po

but again the list of installed files generated by --record includes two it.mo files:

$ python3 setup.py install --prefix ~/.local --record installed-files.txt
$ grep 'it.mo' installed-files.txt 
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/po/it.mo
/home/fede/.local/lib/python3.7/site-packages/frescobaldi-3.1-py3.7.egg/frescobaldi_app/i18n/it.mo

Maybe you didn't throw away the build directory?

@fedelibre
Copy link
Member Author

Maybe you didn't throw away the build directory?

Yep:

$ find build/ -name it.mo | xargs ls -l
-rw-rw-r--. 1 fede fede 339439 16 dic 00.12 build/lib/frescobaldi_app/i18n/it.mo
-rw-rw-r--. 1 fede fede 270661 13 giu  2019 build/lib/frescobaldi_app/po/it.mo

Removing build/ fixes all the missing strings mentioned in this issue except the Help, Close, Reset, Restore Defaults and Apply buttons in the dialogs (as mentioned in my second comment).
Can you confirm on your computer?
Here's an example:

Schermata da 2019-12-19 22-52-49

@wbsoft
Copy link
Collaborator

wbsoft commented Dec 20, 2019

Those strings should come from Qt itself. Will look into it.

@fedelibre
Copy link
Member Author

@wbsoft the strings should come from qttranslations. In Fedora it's the package qt5-qttranslations, which contains the qtbase_LANG.qm files.

I've just installed the package (which was not installed) but this did not solve the problem.

@fedelibre fedelibre changed the title some strings missing from PO files some QDialogButtonBox items are not translated in any language Dec 31, 2019
@fedelibre
Copy link
Member Author

I don't know how to open the binary qm file. But I have checked the ts file in the source repository and it contains the strings we are talking about here, for example Apply.

Do you know why Frescobaldi is not able to use these translations?

@fedelibre
Copy link
Member Author

After having a closer look, I see that these strings are defined in i18n/messages.py (good idea, I think, so we don't have to rely on the presence of qttranslations?) and present in the PO files. However, the interface doesn't use the translated strings.

Here's an example:

#: ../messages.py:34
msgctxt "QDialogButtonBox"
msgid "Apply"
msgstr "Applica"

@wbsoft
Copy link
Collaborator

wbsoft commented Jan 2, 2020

Maybe Qt is using the gtk theme engine?

@fedelibre
Copy link
Member Author

How can I check it?
I've tried also:

frescobaldi --platformtheme qt5ct

but I still see untranslated buttons.

@fedelibre
Copy link
Member Author

I think GNOME is using the Adwaita theme engine. I have qgnomeplatform and adwaita-qt installed on my system. I read on this issue on qgnomeplatform tracker that there is a gtk3 platform plugin in qt, but it's not available on my system: Fedora package qt5-qtstyleplugins is based on this repository which has only gtk2.

@fedelibre
Copy link
Member Author

After having a closer look, I see that these strings are defined in i18n/messages.py (good idea, I think, so we don't have to rely on the presence of qttranslations?) and present in the PO files. However, the interface doesn't use the translated strings.

@wbsoft I've just noticed that frescobaldi_app/i18n/qtranslator.py - according to the first comment - would expect a file named qtmessages.py in the same directory. But currently the Qt strings are in i18n/messages.py.

@wbsoft
Copy link
Collaborator

wbsoft commented Jan 9, 2020

the comment is not correct anymore :-) the qt translations are simply got using the _() call, which gets the translations from the current translation. I'll try to debug this the coming days. My Qt uses a gtk theme, and it seems that some of the buttons come from gtk, qt never calls its own translator to get the strings. But there must be a way to fix this...

@wbsoft
Copy link
Collaborator

wbsoft commented Apr 23, 2020

fixed in 477d7b5

@wbsoft wbsoft closed this as completed Apr 23, 2020
@fedelibre
Copy link
Member Author

For the records, I've just updated the it.po file and I confirm that this issue has been fixed.

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

No branches or pull requests

3 participants