[packagechooser] Assemble the translated name and description

This commit is contained in:
Adriaan de Groot 2019-08-20 05:37:52 -04:00
parent 7b699bfc76
commit ffa899b497

View File

@ -69,10 +69,34 @@ fromComponent( AppStream::Component& component )
{
QVariantMap map;
map.insert( "id", component.id() );
map.insert( "name", component.name() );
map.insert( "description", component.description() );
map.insert( "package", component.packageNames().join( "," ) );
// Assume that the pool has loaded "ALL" locales, but it might be set
// to any of them; get the en_US locale as "untranslated" and then
// loop over Calamares locales (since there is no way to query for
// available locales in the Component) to see if there's anything else.
component.setActiveLocale( QStringLiteral( "en_US" ) );
QString en_name = component.name();
QString en_description = component.description();
map.insert( "name", en_name );
map.insert( "description", en_description );
for ( const QString& locale : CalamaresUtils::Locale::availableTranslations()->localeIds() )
{
component.setActiveLocale( locale );
QString name = component.name();
if ( name != en_name )
{
map.insert( QStringLiteral( "name[%1]" ).arg( locale ), name );
}
QString description = component.description();
if ( description != en_description )
{
map.insert( QStringLiteral( "description[%1]" ).arg( locale ), description );
}
}
auto screenshots = component.screenshots();
if ( screenshots.count() > 0 )
{