Skip to content

Fix system language autodetection on MacOS #22957

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

Merged
merged 8 commits into from
Jul 8, 2025

Conversation

Ryu481
Copy link
Contributor

@Ryu481 Ryu481 commented Jul 3, 2025

Due to a change in MacOS Qlocale returns always english, when there are no language lproj folders in the app bundle. So the program would always start in english no matter what your system language is. This pr adds this folders so Qlocale returns the correct system language. Because of this change the program can detect the system language and, when a translation is available, the program starts in the correct language. The lproj folders are added to the Ressources folder in the app bundle. If new translations are added the corresponding lproj folders should be added for the new languages so that autodetection works for the new translations too. Bugreports in qt about this issue:

https://bugreports.qt.io/browse/QTBUG-72491
https://bugreports.qt.io/browse/QTBUG-63324

legalnotice in different languages on the first start so autodetection works now

German:
German legalnotice

Japanese:
Japanese legalnotice

English:
English legalnotice

@@ -100,6 +156,62 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf
${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns
${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns
${qBittorrent_SOURCE_DIR}/dist/mac/lproj/ar.lproj
Copy link
Member

Choose a reason for hiding this comment

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

I believe there should be a way to make it in a single entry using some wildcard.
Moreover, there may even be a way to create all these folders without storing empty folders in the resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed it so that the whole resources folder gets copied all at once so only one command is needed in the cmake file.

Copy link
Member

Choose a reason for hiding this comment

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

I have changed it so that the whole resources folder gets copied all at once so only one command is needed in the cmake file.

I didn't mean it to be changed so much. Moreover there is another place where the files listed too.
I meant to use something like the one used in another similar case:

file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the names of the lproj folders are generated from the language codes of the .ts files in "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") because of this the folders should automatically be added when new translations are added and there are no empty folders in the project directories.

@glassez glassez added the OS: macOS Issues specific to macOS label Jul 3, 2025
@glassez glassez requested a review from a team July 3, 2025 10:21
xavier2k6
xavier2k6 previously approved these changes Jul 3, 2025
@xavier2k6
Copy link
Member

Can't test - no access to mac, but seems to work from screenshots...

@sledgehammer999
Copy link
Member

Look at the top of src/app/CMakeLists.txt. We already GLOB the .ts files into a variable there. So use that variable.
Also consider if it makes sense to move your new code closer to .ts code at the top.

@Ryu481
Copy link
Contributor Author

Ryu481 commented Jul 3, 2025

The variable from the globbed ts files is now reused and the code is more at the top now. However the code only works if inserted after the add_executable(qbt_app) command.

glassez
glassez previously approved these changes Jul 4, 2025
@glassez glassez added this to the 5.1.3 milestone Jul 4, 2025
Copy link
Member

@Chocobo1 Chocobo1 left a comment

Choose a reason for hiding this comment

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

one last comment

@glassez glassez merged commit f5a93be into qbittorrent:master Jul 8, 2025
15 checks passed
@glassez
Copy link
Member

glassez commented Jul 8, 2025

@Ryu481
Thank you!

@Ryu481 Ryu481 deleted the languageAutodetectionOnMacOS branch July 8, 2025 10:03
@qBittUser
Copy link

This needs to be backported or change it's milestone.

glassez pushed a commit to glassez/qBittorrent that referenced this pull request Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: macOS Issues specific to macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants