quickviewer icon indicating copy to clipboard operation
quickviewer copied to clipboard

[enhancement] add qt translations on mac/windows.

Open pazos opened this issue 6 years ago • 8 comments

At least on mac, I don't expect that most users have qt installed on path. It would be awesome to bundle qt translations within Quickviewer, at least qtbase (used for contextual menus, mac "native" menubar text heurístics ..) and qt (used for graphical menus, like the filechooser).

I'm not sure how to implement this. Some tips would be great.

pazos avatar Jul 24 '18 13:07 pazos

thank you for the request.

Basically, QuickViewer bundles the translation of the application itself and the translation of the Qt libraries.

However, the Mac version has recently been added and has not been tested well yet. Translation should be switched from the 'Language' main menu, but we have not confirmed how the translation of Qt base is.

I will look at the state at the next release.

kanryu avatar Jul 25 '18 00:07 kanryu

Hi @kanryu, thanks for your time and for this wonderful application.

Basically, QuickViewer bundles the translation of the application itself and the translation of the Qt libraries.

Yes, application translation works but qt translation doesn't work. I see that you're using qt_$lang translation instead of qtbase_$lang translation. If I replace the one bundled with the qtbase one, the translation works (at least for spanish).

However, the Mac version has recently been added and has not been tested well yet. Translation should be switched from the 'Language' main menu, but we have not confirmed how the translation of Qt base is.

mac should work the same as other platforms, but you'll need to add a folder per each language you wish to support on Contents/Resources (e.g: Contents/Resources/es.lproj/), this will translate native menus (like folders name on file dialogs...). Sadly this method is not compatible with retranslations (You need to change the whole OS language to see changes in the application), but It is useful to, at least, provide translations for the system language.

pazos avatar Jul 25 '18 22:07 pazos

Mac specifics

without QuickViewer.app/Contents/Resources/es.lproj

test2

with QuickViewer.app/Contents/Resources/es.lproj

test1

if I add just the japanese folder and no english one the system will pick that for this app.

tes23

pazos avatar Jul 25 '18 23:07 pazos

Thank you very much for providing detailed information.

Apparently, the current QuickViewer for Mac seems to be in a state where the text of Qt SDK is not translated into English.

It will probably be necessary to actually check the operation as to whether it is necessary to create the XX.lproj folder for each language. It may be avoidable by modifying the code of the application, or it may be better to adapt it to Mac + Qt's 'method of operation'.

If you can read C++ source code, you may want to examine 'QLanguageSelector :: resetTranslator'.

https://github.com/kanryu/qlanguageselector/blob/476bc4181a2f1b6de6c4e45d611cc69d40c40d31/qlanguageselector.cpp

kanryu avatar Jul 26 '18 00:07 kanryu

Apparently, the current QuickViewer for Mac seems to be in a state where the text of Qt SDK is not translated into English.

No, it works perfectly. As it does on linux.

It will probably be necessary to actually check the operation as to whether it is necessary to create the XX.lproj folder for each language. It may be avoidable by modifying the code of the application, or it may be better to adapt it to Mac + Qt's 'method of operation'.

Not strictly neccesary but shouldn't hurt to create those (empty) folders. Most of qt menus are own widgets and those are translated by qt_base.Just a few are using native mac menus (the file chooser is the only one on QuickViewer AFAICT). Is on these menus when some strings are not translated (and thus displayed in english).

here is a snippet of another project of mine, to create those folders.

LANGUAGES = en de es it pt
# create empty folders to make macOS aware that this project is localized.
RESOURCES_TARGET_DIR = $${TARGET}.app/Contents/Resources
for (project, LANGUAGES) {
    mkpath
    mkpath("$$RESOURCES_TARGET_DIR/$${project}.lproj")
}

If you can read C++ source code, you may want to examine 'QLanguageSelector :: resetTranslator'.

I think that the logic is fine, but you are loading the template qt_ja instead of the translations qtbase_ja.

The template is fine on linux where the user is almost ok with having libraries and frameworks installed, but we don't really need to load

<dependency catalog="qtscript_ja"/>
<dependency catalog="qtquick1_ja"/>
<dependency catalog="qtmultimedia_ja"/>
<dependency catalog="qtxmlpatterns_ja"/>

So switching from qt translations to qtbase translations (and redestributing those files with the program) will do the job. At least it is doing the job for me.

pazos avatar Jul 29 '18 23:07 pazos

Thank you :) I'l test.

kanryu avatar Jul 29 '18 23:07 kanryu

@kanryu: any update on this?. Could I help?

pazos avatar Sep 01 '19 20:09 pazos

@pazos As you know, QuickViewer has not been released on Mac OS for a long time. This is not because we lost the willingness to support, but because we didn't have a build environment. I'll be able to use my MacBook in my new workplace, so it will be released again.

kanryu avatar Sep 02 '19 00:09 kanryu