agateau / nanonote

A minimalist note taking application
Other
57 stars 11 forks source link

Make sure standard actions like Copy or Paste are translated #33

Closed agateau closed 1 year ago

agateau commented 1 year ago

Load Qt translations.

@dlaidig: this should solve your issue with incomplete translations.

dlaidig commented 1 year ago

Unfortunately, on macOS I still get the mixed translation when I switch the system language to German.

I didn't take a detailed look yet, but where do you expect the Qt translations to be loaded from? Some separate files or some qrc thing? In the files of the application package, I noticed the new nanonote_$lang.qm files from your last change, but nothing that hints at Qt translations.

agateau commented 1 year ago

I didn't take a detailed look yet, but where do you expect the Qt translations to be loaded from? Some separate files or some qrc thing? In the files of the application package, I noticed the new nanonote_$lang.qm files from your last change, but nothing that hints at Qt translations.

On Windows, windeployqt installs Qt translations as qt_$lang.qm files. I expected (hoped) that macdeployqt would do the same. I guess it's not the case?

dlaidig commented 1 year ago

Apparently not:

% find . -type f
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/QtCore.prl
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/QtDBus.prl
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/QtGui.prl
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/QtNetwork.prl
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/QtPrintSupport.prl
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/QtSvg
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/Resources/QtSvg.prl
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/QtWidgets.prl
./nanonote.app/Contents/Info.plist
./nanonote.app/Contents/MacOS/nanonote
./nanonote.app/Contents/PlugIns/bearer/libqgenericbearer.dylib
./nanonote.app/Contents/PlugIns/iconengines/libqsvgicon.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqgif.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqicns.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqico.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqjpeg.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqmacheif.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqmacjp2.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqtga.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqtiff.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqwbmp.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqwebp.dylib
./nanonote.app/Contents/PlugIns/platforms/libqcocoa.dylib
./nanonote.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib
./nanonote.app/Contents/PlugIns/styles/libqmacstyle.dylib
./nanonote.app/Contents/Resources/APP_SRCS.icns
./nanonote.app/Contents/Resources/qt.conf
./nanonote.app/Contents/Resources/translations/nanonote_de.qm
./nanonote.app/Contents/Resources/translations/nanonote_en.qm
./nanonote.app/Contents/Resources/translations/nanonote_es.qm
./nanonote.app/Contents/Resources/translations/nanonote_fr.qm

From a quick search, this really seems to be an issue with macdeployqt:

agateau commented 1 year ago

Thanks for investigating this. I think I fixed it. Can you try again?

dlaidig commented 1 year ago

Now there are some Qt translation files but they are not loaded (and it seems like they are in a different location than the app translations).

% find . -type f
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/QtCore.prl
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/QtDBus.prl
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/QtGui.prl
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/QtNetwork.prl
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/QtPrintSupport.prl
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/QtSvg
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtSvg.framework/Versions/5/Resources/QtSvg.prl
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist
./nanonote.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/QtWidgets.prl
./nanonote.app/Contents/Info.plist
./nanonote.app/Contents/MacOS/nanonote
./nanonote.app/Contents/PlugIns/bearer/libqgenericbearer.dylib
./nanonote.app/Contents/PlugIns/iconengines/libqsvgicon.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqgif.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqicns.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqico.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqjpeg.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqmacheif.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqmacjp2.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqtga.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqtiff.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqwbmp.dylib
./nanonote.app/Contents/PlugIns/imageformats/libqwebp.dylib
./nanonote.app/Contents/PlugIns/platforms/libqcocoa.dylib
./nanonote.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib
./nanonote.app/Contents/PlugIns/styles/libqmacstyle.dylib
./nanonote.app/Contents/Resources/APP_SRCS.icns
./nanonote.app/Contents/Resources/qt.conf
./nanonote.app/Contents/Resources/translations/nanonote_de.qm
./nanonote.app/Contents/Resources/translations/nanonote_en.qm
./nanonote.app/Contents/Resources/translations/nanonote_es.qm
./nanonote.app/Contents/Resources/translations/nanonote_fr.qm
./nanonote.app/Contents/Translations/qt_ar.qm
./nanonote.app/Contents/Translations/qt_bg.qm
./nanonote.app/Contents/Translations/qt_ca.qm
./nanonote.app/Contents/Translations/qt_cs.qm
./nanonote.app/Contents/Translations/qt_da.qm
./nanonote.app/Contents/Translations/qt_de.qm
./nanonote.app/Contents/Translations/qt_en.qm
./nanonote.app/Contents/Translations/qt_es.qm
./nanonote.app/Contents/Translations/qt_fa.qm
./nanonote.app/Contents/Translations/qt_fi.qm
./nanonote.app/Contents/Translations/qt_fr.qm
./nanonote.app/Contents/Translations/qt_gd.qm
./nanonote.app/Contents/Translations/qt_gl.qm
./nanonote.app/Contents/Translations/qt_he.qm
./nanonote.app/Contents/Translations/qt_help_ar.qm
./nanonote.app/Contents/Translations/qt_help_bg.qm
./nanonote.app/Contents/Translations/qt_help_ca.qm
./nanonote.app/Contents/Translations/qt_help_cs.qm
./nanonote.app/Contents/Translations/qt_help_da.qm
./nanonote.app/Contents/Translations/qt_help_de.qm
./nanonote.app/Contents/Translations/qt_help_en.qm
./nanonote.app/Contents/Translations/qt_help_es.qm
./nanonote.app/Contents/Translations/qt_help_fr.qm
./nanonote.app/Contents/Translations/qt_help_gl.qm
./nanonote.app/Contents/Translations/qt_help_hu.qm
./nanonote.app/Contents/Translations/qt_help_it.qm
./nanonote.app/Contents/Translations/qt_help_ja.qm
./nanonote.app/Contents/Translations/qt_help_ko.qm
./nanonote.app/Contents/Translations/qt_help_pl.qm
./nanonote.app/Contents/Translations/qt_help_ru.qm
./nanonote.app/Contents/Translations/qt_help_sk.qm
./nanonote.app/Contents/Translations/qt_help_sl.qm
./nanonote.app/Contents/Translations/qt_help_tr.qm
./nanonote.app/Contents/Translations/qt_help_uk.qm
./nanonote.app/Contents/Translations/qt_help_zh_CN.qm
./nanonote.app/Contents/Translations/qt_help_zh_TW.qm
./nanonote.app/Contents/Translations/qt_hu.qm
./nanonote.app/Contents/Translations/qt_it.qm
./nanonote.app/Contents/Translations/qt_ja.qm
./nanonote.app/Contents/Translations/qt_ko.qm
./nanonote.app/Contents/Translations/qt_lt.qm
./nanonote.app/Contents/Translations/qt_lv.qm
./nanonote.app/Contents/Translations/qt_pl.qm
./nanonote.app/Contents/Translations/qt_pt.qm
./nanonote.app/Contents/Translations/qt_ru.qm
./nanonote.app/Contents/Translations/qt_sk.qm
./nanonote.app/Contents/Translations/qt_sl.qm
./nanonote.app/Contents/Translations/qt_sv.qm
./nanonote.app/Contents/Translations/qt_tr.qm
./nanonote.app/Contents/Translations/qt_uk.qm
./nanonote.app/Contents/Translations/qt_zh_CN.qm
./nanonote.app/Contents/Translations/qt_zh_TW.qm
% du -hs nanonote.app/Contents/Translations
1,5M    nanonote.app/Contents/Translations
agateau commented 1 year ago

OK, progress at last! I picked the location based on the Qt bug report, but it seems it's wrong. Can you edit main.cpp and add a qDebug() << qtTranslationsDir; after line 21? That should tell us where the translations should be installed.

dlaidig commented 1 year ago

This is getting increasingly weird...

The output is "/Applications/nanonote.app/Contents/translations" (i.e., correct but lower case). This is actually not an issue since apparently somebody once thought that case insensitive and case preserving file systems are a good idea...

What I noticed is that most translation files are suspiciously small:

% ls -l /Applications/nanonote.app/Contents/translations
total 3144
-rw-r--r--@ 1 laidig  admin     130 Nov  6  2020 qt_ar.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_bg.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_ca.qm
-rw-r--r--@ 1 laidig  admin     157 Nov  6  2020 qt_cs.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_da.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_de.qm
-rw-r--r--@ 1 laidig  admin      16 Nov  6  2020 qt_en.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_es.qm
-rw-r--r--@ 1 laidig  admin  293121 Nov  6  2020 qt_fa.qm
-rw-r--r--@ 1 laidig  admin     117 Nov  6  2020 qt_fi.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_fr.qm
-rw-r--r--@ 1 laidig  admin      70 Nov  6  2020 qt_gd.qm
-rw-r--r--@ 1 laidig  admin  323590 Nov  6  2020 qt_gl.qm
-rw-r--r--@ 1 laidig  admin      83 Nov  6  2020 qt_he.qm
-rw-r--r--@ 1 laidig  admin    8743 Nov  6  2020 qt_help_ar.qm
-rw-r--r--@ 1 laidig  admin   10599 Nov  6  2020 qt_help_bg.qm
-rw-r--r--@ 1 laidig  admin    7444 Nov  6  2020 qt_help_ca.qm
-rw-r--r--@ 1 laidig  admin   15297 Nov  6  2020 qt_help_cs.qm
-rw-r--r--@ 1 laidig  admin    4795 Nov  6  2020 qt_help_da.qm
-rw-r--r--@ 1 laidig  admin    7570 Nov  6  2020 qt_help_de.qm
-rw-r--r--@ 1 laidig  admin      16 Nov  6  2020 qt_help_en.qm
-rw-r--r--@ 1 laidig  admin   10704 Nov  6  2020 qt_help_es.qm
-rw-r--r--@ 1 laidig  admin   10922 Nov  6  2020 qt_help_fr.qm
-rw-r--r--@ 1 laidig  admin   10891 Nov  6  2020 qt_help_gl.qm
-rw-r--r--@ 1 laidig  admin   10284 Nov  6  2020 qt_help_hu.qm
-rw-r--r--@ 1 laidig  admin   10612 Nov  6  2020 qt_help_it.qm
-rw-r--r--@ 1 laidig  admin    7917 Nov  6  2020 qt_help_ja.qm
-rw-r--r--@ 1 laidig  admin    5708 Nov  6  2020 qt_help_ko.qm
-rw-r--r--@ 1 laidig  admin    9673 Nov  6  2020 qt_help_pl.qm
-rw-r--r--@ 1 laidig  admin    7288 Nov  6  2020 qt_help_ru.qm
-rw-r--r--@ 1 laidig  admin   10388 Nov  6  2020 qt_help_sk.qm
-rw-r--r--@ 1 laidig  admin   10363 Nov  6  2020 qt_help_sl.qm
-rw-r--r--@ 1 laidig  admin    4629 Nov  6  2020 qt_help_tr.qm
-rw-r--r--@ 1 laidig  admin    9750 Nov  6  2020 qt_help_uk.qm
-rw-r--r--@ 1 laidig  admin    6441 Nov  6  2020 qt_help_zh_CN.qm
-rw-r--r--@ 1 laidig  admin    9301 Nov  6  2020 qt_help_zh_TW.qm
-rw-r--r--@ 1 laidig  admin     146 Nov  6  2020 qt_hu.qm
-rw-r--r--@ 1 laidig  admin     153 Nov  6  2020 qt_it.qm
-rw-r--r--@ 1 laidig  admin     146 Nov  6  2020 qt_ja.qm
-rw-r--r--@ 1 laidig  admin     146 Nov  6  2020 qt_ko.qm
-rw-r--r--@ 1 laidig  admin  165383 Nov  6  2020 qt_lt.qm
-rw-r--r--@ 1 laidig  admin      89 Nov  6  2020 qt_lv.qm
-rw-r--r--@ 1 laidig  admin     161 Nov  6  2020 qt_pl.qm
-rw-r--r--@ 1 laidig  admin   70334 Nov  6  2020 qt_pt.qm
-rw-r--r--@ 1 laidig  admin     164 Nov  6  2020 qt_ru.qm
-rw-r--r--@ 1 laidig  admin     157 Nov  6  2020 qt_sk.qm
-rw-r--r--@ 1 laidig  admin  228428 Nov  6  2020 qt_sl.qm
-rw-r--r--@ 1 laidig  admin   65851 Nov  6  2020 qt_sv.qm
-rw-r--r--@ 1 laidig  admin     110 Nov  6  2020 qt_tr.qm
-rw-r--r--@ 1 laidig  admin     164 Nov  6  2020 qt_uk.qm
-rw-r--r--@ 1 laidig  admin  117347 Nov  6  2020 qt_zh_CN.qm
-rw-r--r--@ 1 laidig  admin     141 Nov  6  2020 qt_zh_TW.qm

Since qt_sv.qm is larger than qt_de.qm, I set my primary language to Swedish. I also added another qDebug output to check if a Qt translation is actually loaded.

With the language set to Swedish, it actually loaded something, while for German, it did not (even though the file exists). In both cases, it did not have any effect and the standard action kept being named "Copy", "Paste" etc.

agateau commented 1 year ago

Ah! I think it should be qtbase_*.qm and not qt_*.qm :facepalm:

agateau commented 1 year ago

Just force-pushed the change.

dlaidig commented 1 year ago

But the code in main.cpp is still trying to load the qt_*.qm files, right?

dlaidig commented 1 year ago

Fyi, I just renamed the files to test this and it works. :)

agateau commented 1 year ago

Ahhh good point. I wonder how I tested it... Anyway, I changed main.cpp to use qtbase instead of qt. Should be good now :crossed_fingers:.

dlaidig commented 1 year ago

Yes, now it works for me on macOS :)

agateau commented 1 year ago

Thanks for all the feedback, merging the PR.