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

Qt GUI: Implement translations + monospaced font customization #1032

Merged
merged 4 commits into from
Feb 17, 2025

Conversation

cjee21
Copy link
Collaborator

@cjee21 cjee21 commented Feb 15, 2025

Translations:
Screenshot 2025-02-16 141005

English French
Screenshot 2025-02-16 140914 Screenshot 2025-02-16 140900
Screenshot 2025-02-16 140950 Screenshot 2025-02-16 140935

Monospaced font customization (for sheet/text view):
Screenshot 2025-02-16 163005
Screenshot 2025-02-16 163014

@cjee21 cjee21 marked this pull request as draft February 15, 2025 18:59
@cjee21 cjee21 marked this pull request as ready for review February 15, 2025 20:49
@cjee21 cjee21 changed the title Qt GUI: Initial translation implementation Qt GUI: Implement translations Feb 15, 2025
@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 15, 2025

After this, others can use Qt Linguist to translate the UI strings.

@cjee21 cjee21 marked this pull request as draft February 16, 2025 04:36
@cjee21 cjee21 marked this pull request as ready for review February 16, 2025 06:17
@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 16, 2025

By the way, CJK languages have misaligned text output in MediaInfoLib.
Is it a known behaviour? @JeromeMartinez

Screenshot 2025-02-16 164726
Screenshot 2025-02-16 164753

@cjee21 cjee21 changed the title Qt GUI: Implement translations Qt GUI: Implement translations + monospaced font customization Feb 16, 2025
@cjee21 cjee21 force-pushed the qt-translation branch 3 times, most recently from 7b1c2b8 to 8cf155a Compare February 16, 2025 14:15
Copy link
Member

@JeromeMartinez JeromeMartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the proposal but

After this, others can use Qt Linguist to translate the UI strings.

No, because the "upstream" is the CSV files, and the Qt translation files need to be updated from theses CSV files.
Having a "fork" in the translation files will be a burden at long term.

Mandatory thing is, as it is done for the macOS translations, an automated script that permits us to easily update the Qt translation files from time to time.
Optionally, if you want that the users are able to use Qt Linguist, an automated script that permits use to easily update the CSV files when there is a Qt files update.

@JeromeMartinez
Copy link
Member

By the way, CJK languages have misaligned text output in MediaInfoLib.
Is it a known behaviour? @JeromeMartinez

No, it would deserve a patch.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 16, 2025

Mandatory thing is, as it is done for the macOS translations, an automated script that permits us to easily update the Qt translation files from time to time.

I did use a script to update the Qt translation files from the csv for this PR. Some strings don't match the VCL GUI so they are not translated.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 16, 2025

In case it is not clear, the Qt translation is only for the UI part. MediaInfoLib still uses the csv files directly.

@JeromeMartinez
Copy link
Member

I did use a script to update the Qt translation files from the csv for this PR.

I don't see the script in the PR.

Some strings don't match the VCL GUI so they are not translated.

I don't understand.
Anyway, I need to be able to create all the files (ts & qm) from the CSV files. If there is new string not in the VCL, it needs to be added to the CSV files because it would be deleted by the script (I want to be able to create the output files fully, so as if they are not there) + The plan is to have the same features everywhere and the features you added in the Qt version will be at the minimum in the macOS version, and maybe in the VCL version if I keep it longer.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 16, 2025

The .ts files are generated from the Qt project/source files using Qt's lupdate CLI tool. They contain all the translatable strings in the Qt GUI. The translations can then be added using Qt Linguist or with a script. The Qt GUI uses different strings for the menus etc so the script cannot match everything properly to the csv. The script is not perfect also. The .qm are generated from .ts using Qt's lrelease CLI tool.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 16, 2025

I see no easy way to reliably copy translations from the csv to ts due to the different way Qt handles string identification.

@JeromeMartinez
Copy link
Member

The .ts files are generated from the Qt project/source files using Qt's lupdate CLI tool. [...] The .qm are generated from .ts using Qt's lrelease CLI tool.

Please provide something similar to https://github.com/MediaArea/MediaInfo/tree/master/Source/GUI/Cocoa/_i18n i.e. a documentation and/or a batch for having a quick way to do an update.

The Qt GUI uses different strings for the menus etc so the script cannot match everything properly to the csv. The script is not perfect also.

Even if not perfect, but I guess that we could use the English sentences as a "key" for fetching the translation from the other files (English sentences --> CSV first column --> translations), and maybe not creating the files from scratch but being able to update them by catching the English sentence ("source" element) in the Qt files and filing the "translation" element.Creating new lines in the CSV when you have new sentences.

I don't want to have a fork in the translations and/or having to manually fill different places for the same translation.

@cjee21 cjee21 force-pushed the qt-translation branch 2 times, most recently from e7bcc6a to b97e9d3 Compare February 17, 2025 05:59
@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 17, 2025

Okay, fully automated now. I changed some strings in Qt GUI to match as much as possible with existing translation keys. There are still some strings left untranslated as they are no equivalent in the existing translations. I will leave that for others to translate in future. Just need to add those entries in the CSV and run the update script. Existing VCL GUI also has untranslated strings anyway.

It's easier than VCL, when adding new text to the Qt GUI form, just add corresponding entry to CSV and run the update script. No coding needed for translations.

There is no noticeable glitch or delay with loading the language list in Preferences for Qt unlike the VCL one.

Creating new lines in the CSV when you have new sentences.

This cannot be automated as the .ts generated by Qt also contains some strings that do not need to be translated.

Latest screenshots:
Screenshot 2025-02-17 130444
Screenshot 2025-02-17 130511

Screenshot 2025-02-17 141914
Screenshot 2025-02-17 141855

@JeromeMartinez
Copy link
Member

Okay, fully automated now.

Thank you.
But I have an issue reproducing your workflow, the .ts files have this formatting diff:

-<TS version="2.1" language="ar" sourcelanguage="en">
+<TS language="ar" sourcelanguage="en" version="2.1">

I am testing with Qt 6.8.2 Windows.
It would be better to have the files as created by the current latest version of Qt. Or how is it that you have a different XML attribute order there?

I changed some strings in Qt GUI to match as much as possible with existing translation keys.

Thank you.

There are still some strings left untranslated as they are no equivalent in the existing translations. I will leave that for others to translate in future. Just need to add those entries in the CSV and run the update script.

Would have been a plus to fill the CSV with lines with 2 columns filled (1st one with a short ID without space, some ";", up to the English related column) but I understand that this is already a lot for you, I may do that when I do more QA on the translations before offering the Qt version.

Existing VCL GUI also has untranslated strings anyway.

Yes, this is on our QA todo-list.

There is no noticeable glitch or delay with loading the language list in Preferences for Qt unlike the VCL one.

I need to change the current behavior of the VCL and loading a small file instead of all CSV files, but not related to here.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 17, 2025

It would be better to have the files as created by the current latest version of Qt. Or how is it that you have a different XML attribute order there?

I just use the .cmd file to generate/update all the .ts and .qm. I'm using latest Qt 6.8.2 here too.
I don't think I have ever seen order like yours even when manually translating with Linguist.

@JeromeMartinez
Copy link
Member

I don't think I have ever seen order like yours even when manually translating with Linguist.

I just run your .cmd, so weird!
Anyway, not a big deal, and we'll see how we'll manage that when we do the updates.

@cjee21
Copy link
Collaborator Author

cjee21 commented Feb 17, 2025

I just run your .cmd, so weird! Anyway, not a big deal,

I just tried again.... On this branch, I deleted everything in Translations folder then run the .cmd.... I got perfect match with this branch, GitHub Desktop shows nothing to commit.

I suspect it may be due to the xml parsing library in Python may be different somehow? Yours seems to be reordering everything in alphabetical order.

Mine:

Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as ET
>>> ET.VERSION
'1.3.0'

Checking previous commit, when Qt Linguist was used instead of the script:

<TS version="2.1" language="en_US" sourcelanguage="en_US">

@JeromeMartinez
Copy link
Member

I suspect it may be due to the xml parsing library in Python may be different somehow?

Updated my old Python 3 and I have the same thing as you now.

@JeromeMartinez JeromeMartinez merged commit b2f4bd1 into MediaArea:master Feb 17, 2025
7 checks passed
@cjee21 cjee21 deleted the qt-translation branch February 17, 2025 15:58
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

Successfully merging this pull request may close these issues.

2 participants