KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
1.03k stars 68 forks source link

support Qt's translation system #429

Open Be-ing opened 1 year ago

Be-ing commented 1 year ago
LeonMatthesKDAB commented 1 year ago

We'd also have to wrap the tr call and friends, right? Also, how would Qt find all the strings to be translated? :thinking: Or should we rely on Rust-native translations for rust generated strings?

ahayzen-kdab commented 1 year ago

Right, I left out the translation and locale related types in #291 as these are view layer items (that should be in the QML / Widgets code). I don't think we should add tr support to Rust code, instead you should expose enums from Rust to the view then have UI strings etc.

So then I don't think we need QLocale yet ? and don't really need QTranslator, except for Rust-only projects potentially to use QTranslator::load and install that to the QCoreApplication::installTranslator.

The only part then left is if you are writing a cargo project then you need a way to build the translation files, this part should be added to cxx-qt-build / qt-build-utils.

Be-ing commented 1 year ago

Right, the point is to be able to setup QTranslator without needing C++ or CMake like https://github.com/stdying/weibo_qt/blob/dcbd3e28432453a955fa71c76d51ca2b4f29472f/cpp/main.cpp#L16