[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:
parent
7dc450edb4
commit
3e72635204
@ -80,14 +80,20 @@ BrandingLoader::tryLoad( QTranslator* translator )
|
|||||||
{
|
{
|
||||||
return false;
|
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 );
|
QString brandingTranslationsDirPath( m_prefix );
|
||||||
brandingTranslationsDirPath.truncate( m_prefix.lastIndexOf( QDir::separator() ) );
|
brandingTranslationsDirPath.truncate( lastDirSeparator );
|
||||||
QDir brandingTranslationsDir( brandingTranslationsDirPath );
|
QString filenameBase( m_prefix );
|
||||||
if ( brandingTranslationsDir.exists() )
|
filenameBase.remove( 0, lastDirSeparator + 1 );
|
||||||
|
|
||||||
|
|
||||||
|
if ( QDir( brandingTranslationsDirPath ).exists() )
|
||||||
{
|
{
|
||||||
QString filenameBase( m_prefix );
|
const QString fileName = QStringLiteral( "%1_%2" ).arg( filenameBase, m_localeName );
|
||||||
filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 );
|
cDebug() << Logger::SubEntry << "Loading" << fileName << "from" << brandingTranslationsDirPath;
|
||||||
if ( translator->load( m_localeName, filenameBase, "_", brandingTranslationsDir.absolutePath() ) )
|
if ( translator->load( fileName, brandingTranslationsDirPath ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName;
|
cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user