Cockatrice/libcockatrice_utility/libcockatrice/utility
BruebachL 0934380a5c
[Translations] Load Qt's own translations and build ours with the binary (#7384)
* [Translations] Load Qt's own translations and build ours with the binary

Three separate bugs kept translations from working.

installNewTranslator() loaded the application translation into
qtTranslator. QTranslator discards its previous contents on every load, so
that wiped the qt_<lang>.qm loaded one line earlier and installed an empty
translator instead. Qt's own strings were never translated on any platform.
Give each file its own translator.

QLibraryInfo::path(TranslationsPath) was the only directory searched for
Qt's translations. A relocated Qt can report a path that does not exist: the
KDE Flatpak runtime reports /usr/translations while its files live in
/usr/share/qt6/translations. Probe the usual install layouts and only hand
back the ones that exist.

The .qm files were attached to the default build target only, so building
the executable on its own left it without any translations and the language
selector empty. Attach them to the target as well.

Move the shared lookup into TranslationLoader so client and Oracle cannot
drift again, and have it report a missing translation at debug level. An
unset language is the default for English, which has no file to begin with,
and warning about it only added noise to every fresh debug log.

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>

* [Tests] Define main() in translation_loader_test

Without a GTest installation the fallback in tests/CMakeLists.txt links
only gtest, not gtest_main, so the test has to bring its own main(). Every
other test already does; only this one relied on the distribution package
and failed to link on CI.

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>

* [Tests] Put the translation loader fixture next to the test executable

A multi-config generator (MSBuild, Xcode) writes the executable to a
per-config subdirectory while the .qm stays in the current binary
directory, so applicationDirPath() never saw the fixture and
ABuildTreeFindsTheTranslationsNextToTheExecutable failed on Windows.

* [Translations] Depend on Qt's lrelease target and skip the loader test without lrelease

Attaching the .qm custom commands to a second custom target races with
Qt's own <Project>_lrelease target on MSBuild/Makefiles and is rejected
by Xcode, so depend on Qt's target instead. Only build the translation
loader test when Qt6::lrelease is available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 15:04:30 +02:00
..
card_ref.h [DeckList] Move metadata into struct (#6380) 2025-11-30 13:09:09 +01:00
clamped_arithmetic.h Unify counter clamp arithmetic into shared addClamped() helper (#7009) 2026-06-28 16:10:57 -07:00
color.h [Game][Counters] Split counters into AbstractCounter (graphics) and CounterState (logic) (#6917) 2026-05-21 20:16:28 +02:00
counter_limits.h Split trice_limits.h into dedicated headers (#7025) 2026-06-29 14:37:52 -07:00
cryptoutil.cpp [Security] Use a CSPRNG for salts, tokens, and RNG seeding (#7192) 2026-09-04 13:49:18 +02:00
cryptoutil.h [Security] Use a CSPRNG for salts, tokens, and RNG seeding (#7192) 2026-09-04 13:49:18 +02:00
days_years_between.h [Room][UserList] Introduce style delegate (#6981) 2026-06-26 20:52:24 -04:00
dice_limits.h Split trice_limits.h into dedicated headers (#7025) 2026-06-29 14:37:52 -07:00
expression.cpp style: Add braces to all control flow statements (#6887) 2026-05-16 19:19:53 +02:00
expression.h Turn Card, Deck_List, Protocol, RNG, Network (Client, Server), Settings and Utility into libraries and remove cockatrice_common. (#6212) 2025-10-09 07:36:12 +02:00
levenshtein.cpp style: Add braces to all control flow statements (#6887) 2026-05-16 19:19:53 +02:00
levenshtein.h Standardize Doxygen documentation (#6885) 2026-05-21 22:58:07 +02:00
macros.h Turn Card, Deck_List, Protocol, RNG, Network (Client, Server), Settings and Utility into libraries and remove cockatrice_common. (#6212) 2025-10-09 07:36:12 +02:00
passwordhasher.cpp [Security] Use a CSPRNG for salts, tokens, and RNG seeding (#7192) 2026-09-04 13:49:18 +02:00
passwordhasher.h Turn Card, Deck_List, Protocol, RNG, Network (Client, Server), Settings and Utility into libraries and remove cockatrice_common. (#6212) 2025-10-09 07:36:12 +02:00
peglib.h Update peglib to v1.16.0 (#7134) 2026-08-17 22:52:30 +02:00
playmat_params.h [Game] Playmats (#7101) 2026-08-21 10:40:49 +02:00
qt_utils.h Add subtype breakdown counter for card selection (#6923) 2026-06-27 15:53:21 -07:00
report_categories.cpp [Server/Client] Unify report categories (#7345) 2026-09-24 18:37:54 +02:00
report_categories.h [Server/Client] Unify report categories (#7345) 2026-09-24 18:37:54 +02:00
server_rate_limiter.cpp [PictureLoader] Schedule exponential backoff on 429 - Too many request handler and call failed on fail (#7053) 2026-08-08 22:55:27 +02:00
server_rate_limiter.h [PictureLoader] Schedule exponential backoff on 429 - Too many request handler and call failed on fail (#7053) 2026-08-08 22:55:27 +02:00
string_limits.h [Server/Client/Protocol] Reporting users + moderation queue functionality (#7091) 2026-08-21 15:00:13 +02:00
translation_loader.cpp [Translations] Load Qt's own translations and build ours with the binary (#7384) 2026-10-03 15:04:30 +02:00
translation_loader.h [Translations] Load Qt's own translations and build ours with the binary (#7384) 2026-10-03 15:04:30 +02:00
warning_categories.cpp [Server/Client/Protocol] Reporting users + moderation queue functionality (#7091) 2026-08-21 15:00:13 +02:00
warning_categories.h [Server/Client/Protocol] Reporting users + moderation queue functionality (#7091) 2026-08-21 15:00:13 +02:00
zone_names.h Refactor zone names (#6686) 2026-03-12 00:34:05 +01:00