Add support for locales in /usr/share/i18n/SUPPORTED

This commit is contained in:
Teo Mrnjavac 2016-05-27 17:14:17 +02:00
parent 893417d26e
commit 9450290212

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -225,10 +225,28 @@ LocalePage::init( const QString& initialRegion,
}
emit m_tzWidget->locationChanged( m_tzWidget->getCurrentLocation() );
// Fill in meaningful locale/charset lines from locale.gen
// Some distros come with a meaningfully commented and easy to parse locale.gen,
// and others ship a separate file /usr/share/i18n/SUPPORTED with a clean list of
// supported locales. We first try that one, and if it doesn't exist, we fall back
// to parsing the lines from locale.gen
m_localeGenLines.clear();
QFile localeGen( localeGenPath );
QFile supported( "/usr/share/i18n/SUPPORTED" );
QByteArray ba;
if ( supported.exists() &&
supported.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
ba = supported.readAll();
supported.close();
foreach ( QByteArray line, ba.split( '\n' ) )
{
m_localeGenLines.append( QString::fromLatin1( line.simplified() ) );
}
}
else
{
QFile localeGen( localeGenPath );
if ( localeGen.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
ba = localeGen.readAll();
@ -261,6 +279,7 @@ LocalePage::init( const QString& initialRegion,
m_localeGenLines.append( lineString );
}
}
}