I'm trying to make translations work for Krita. On starting the
application, I want to check what the user's system language is
and what the override language from the language selection dialog
is.
The problem is that the translations are located here:
Windows
The translations are in bin/../share/locale
Linux
The translations are in bin/../share/locale
OSX
The translations are in krita.app/Contents/MacOS/../share/locale
In other words, the translations are located relative to the
application binary. I add these locations to the XDG_DATA_DIRS
environment variable in my main.
However, KCatalog::catalogLocaleDir is run before the main runs,
and uses QStandardPaths to find the location of the translations.
That's before the XDG_DATA_DIRS environment variable is set.
Starting krita from a shell script or a batch file or a second
executable that starts the real executable is not an acceptable
hack; we did that before, and it gives loads of problems.
I'm now trying this, in my main, before any widgets are created:
// Get the override language from the langu8age selection dialog
const QString configPath =
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings languageoverride(configPath +
QStringLiteral("/klanguageoverridesrc"), QSettings::IniFormat);
languageoverride.beginGroup(QStringLiteral("Language"));
QString language = languageoverride.value(qAppName(), "").toString();
if (!language.isEmpty()) {
KLocalizedString::setLanguages(language.split(":"));
}
else {
// And if there isn't one, check the one set by the system
QLocale locale = QLocale::system();
if (locale.bcp47Name() != QStringLiteral("en")) {
KLocalizedString::setLanguages(QStringList() << locale.bcp47Name());
}
}
The first part works, the language from the override file is used.
The second part doesn't work. If I start krita like
LANGUAGE=ja krita
Then the setLanguages call is made, but the application is
still in English. I've tried to debug klocalizedstring, but
I cannot even figure out why the first setLanguages call works,
let alone why the second one doesn't work.
I've also tried to force a change of the languages variable, like:
KLocalizedString::setLanguages(QStringList() << "en);
KLocalizedString::setLanguages(QStringList() << locale.bcp47Name());
And that also didn't work.
See also
https://quickgit.kde.org/?p=krita.git&a=commit&h=5015920f2b24d63b04c82cbf69c674de06ab8abc
Is there any way to make this work?
--
Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org
_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel