Merge branch 'translate-packagechooser'

FIXES #1228

The label on the left can now be specified (and translated)
in the config file. The strings corresponding to "nothing
selected" from PackageChooserPage.cpp L33-34 can already
be specified in the *items* section.
main
Adriaan de Groot 5 years ago
commit c2f1070f2a

@ -32,6 +32,7 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h"
#include "utils/Variant.h"
@ -46,6 +47,7 @@ PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
, m_widget( nullptr )
, m_model( nullptr )
, m_mode( PackageChooserMode::Required )
, m_stepName( nullptr )
{
emit nextStatusChanged( false );
}
@ -58,13 +60,14 @@ PackageChooserViewStep::~PackageChooserViewStep()
m_widget->deleteLater();
}
delete m_model;
delete m_stepName;
}
QString
PackageChooserViewStep::prettyName() const
{
return tr( "Packages" );
return m_stepName ? m_stepName->get() : tr( "Packages" );
}
@ -167,12 +170,12 @@ void
PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
QString mode = CalamaresUtils::getString( configurationMap, "mode" );
bool ok = false;
bool mode_ok = false;
if ( !mode.isEmpty() )
{
m_mode = roleNames().find( mode, ok );
m_mode = roleNames().find( mode, mode_ok );
}
if ( !ok )
if ( !mode_ok )
{
m_mode = PackageChooserMode::Required;
}
@ -185,6 +188,16 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
m_id = moduleInstanceKey().split( '@' ).last();
}
bool labels_ok = false;
auto labels = CalamaresUtils::getSubMap( configurationMap, "labels", labels_ok );
if ( labels_ok )
{
if ( labels.contains( "step" ) )
{
m_stepName = new CalamaresUtils::Locale::TranslatedString( labels, "step" );
}
}
bool first_time = !m_model;
if ( configurationMap.contains( "items" ) )
{

@ -20,6 +20,7 @@
#define PACKAGECHOOSERVIEWSTEP_H
#include "PluginDllMacro.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"
@ -65,6 +66,7 @@ private:
// Configuration
PackageChooserMode m_mode;
QString m_id;
CalamaresUtils::Locale::TranslatedString *m_stepName; // As it appears in the sidebar
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )

@ -20,6 +20,19 @@
# or one-or-more).
mode: required
# Human-visible strings in this module. These are all optional.
# The following translated keys are used:
# - *step*, used in the overall progress view (left-hand pane)
#
# Each key kan have a [locale] added to it, which is used as
# the translated string for that locale. For the strings
# associated with the "no-selection" item, see *items*, below
# with the explicit id "".
#
labels:
step: "Packages"
step[nl]: "Pakketten"
# Items to display in the chooser. In general, this should be a
# pretty short list to avoid overwhelming the UI. This is a list
# of objects, and the items are displayed in list order.

Loading…
Cancel
Save