>> […]
>> So the question is what the correct replacement for code like this is:
>>
>>     // from qtbase/examples/corelib/mimetypes/mimetypebrowser/main.cpp
>>     QTranslator translator;
>>     if (translator.load(QLocale::system(), "qtbase"_L1, "_"_L1,
>>                         QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
>> { app.installTranslator(&translator);
>>     }
>>
>>
>> I assume the right pattern is using a while-loop until one of the loads
>> succeeded, rather than loading them all in a for-loop.

>
> Now that you mentioned it, that one in particular deserves more thought. There
> is a lot of code doing exactly the same and one QTranslator can only load one
> translation.

>
> So, first, we should probably add functions to QTranslator and/or
> QStandardPaths to find the translations so we don't have to deploy the 
> looping.
> Second, we should investigate whether QTranslator should be able to keep
> multiple translation files: if we can have multiple translation files, can 
> more
> than one of them contain content? And if so, are they additive or do they
> replace?


I would prefer not to add even more variants to QTranslator::load(). The current
API is bad enough already ...

Instead, the canonical way to solve this is to merge the Qt translations at 
compile time:

https://codereview.qt-project.org/c/qt/qtbase/+/756031

Though this example is in qtbase, which prevents us from using QtLinguistTools 
(?)

So for this _specific_ example, we probably should just fall back to 
QLI::paths().first():

https://codereview.qt-project.org/c/qt/qtbase/+/756032

Kai


Confidential
-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to