Finding local translations?

David Faure faure at kde.org
Sat Apr 9 16:38:20 UTC 2016


On Thursday 07 April 2016 11:56:59 Boudewijn Rempt wrote:
> 
> 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.

A simple solution to that is to set the env var in a Q_CONSTRUCTOR_FUNCTION :

void hackXdgDataDirs()
{
   qputenv("XDG_DATA_DIRS", "somevalue");
}
Q_CONSTRUCTOR_FUNCTION(hackXdgDataDirs)

This will run before main().
Whether it runs before the other things that run before main, like KCatalog,
that's less sure. YMMV.

Note: this is just a reply to "how to set something before main()",
it might not be the best solution overall to this problem, dunno.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



More information about the Kde-frameworks-devel mailing list