[libcalamares] Fix path-search for loading branding-translation

- log which path is actually being used
- there are two overloads for QTranslator::load(); the intention
  was to call `QTranslator::load(const QLocale&, ...)`, but the
  types of the arguments were wrong, leading to the other
  overload being called, and interpreting the locale-name
  (e.g. "nl") as a full filename.

Improve logging, call the "other" overload with the right parameters
and drop the not-needed ones.

FIXES #1961
This commit is contained in:
Adriaan de Groot 2022-05-29 00:49:38 +02:00
parent 7dc450edb4
commit 3e72635204

View File

@ -80,14 +80,20 @@ BrandingLoader::tryLoad( QTranslator* translator )
{
return false;
}
// This is working backwards against m_prefix containing both
// a path and a branding-name. Split it in path + branding-name.
const int lastDirSeparator = m_prefix.lastIndexOf( QDir::separator() );
QString brandingTranslationsDirPath( m_prefix );
brandingTranslationsDirPath.truncate( m_prefix.lastIndexOf( QDir::separator() ) );
QDir brandingTranslationsDir( brandingTranslationsDirPath );
if ( brandingTranslationsDir.exists() )
brandingTranslationsDirPath.truncate( lastDirSeparator );
QString filenameBase( m_prefix );
filenameBase.remove( 0, lastDirSeparator + 1 );
if ( QDir( brandingTranslationsDirPath ).exists() )
{
QString filenameBase( m_prefix );
filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 );
if ( translator->load( m_localeName, filenameBase, "_", brandingTranslationsDir.absolutePath() ) )
const QString fileName = QStringLiteral( "%1_%2" ).arg( filenameBase, m_localeName );
cDebug() << Logger::SubEntry << "Loading" << fileName << "from" << brandingTranslationsDirPath;
if ( translator->load( fileName, brandingTranslationsDirPath ) )
{
cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName;
return true;