|
|
@ -24,17 +24,19 @@ namespace CalamaresUtils
|
|
|
|
namespace Locale
|
|
|
|
namespace Locale
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Label::Label()
|
|
|
|
Label::Label( QObject* parent )
|
|
|
|
: m_locale( QLocale() )
|
|
|
|
: QObject( parent )
|
|
|
|
|
|
|
|
, m_locale( QLocale() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_localeId = m_locale.name();
|
|
|
|
m_localeId = m_locale.name();
|
|
|
|
|
|
|
|
|
|
|
|
setLabels( QString(), LabelFormat::IfNeededWithCountry );
|
|
|
|
setLabels( QString(), LabelFormat::IfNeededWithCountry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Label::Label( const QString& locale, LabelFormat format )
|
|
|
|
Label::Label( const QString& locale, LabelFormat format, QObject* parent )
|
|
|
|
: m_locale( Label::getLocale( locale ) )
|
|
|
|
: m_locale( Label::getLocale( locale ) )
|
|
|
|
, m_localeId( locale )
|
|
|
|
, m_localeId( locale )
|
|
|
|
|
|
|
|
, QObject( parent )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setLabels( locale, format );
|
|
|
|
setLabels( locale, format );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -42,6 +44,7 @@ Label::Label( const QString& locale, LabelFormat format )
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Label::setLabels( const QString& locale, LabelFormat format )
|
|
|
|
Label::setLabels( const QString& locale, LabelFormat format )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
emit localeIdChanged(m_localeId);
|
|
|
|
//: language[name] (country[name])
|
|
|
|
//: language[name] (country[name])
|
|
|
|
QString longFormat = QObject::tr( "%1 (%2)" );
|
|
|
|
QString longFormat = QObject::tr( "%1 (%2)" );
|
|
|
|
|
|
|
|
|
|
|
@ -62,8 +65,10 @@ Label::setLabels( const QString& locale, LabelFormat format )
|
|
|
|
countryName = m_locale.nativeCountryName();
|
|
|
|
countryName = m_locale.nativeCountryName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_label = needsCountryName ? longFormat.arg( languageName, countryName ) : languageName;
|
|
|
|
m_label = needsCountryName ? longFormat.arg( languageName, countryName ) : languageName;
|
|
|
|
|
|
|
|
emit labelChanged(m_label);
|
|
|
|
m_englishLabel = needsCountryName ? longFormat.arg( englishName, QLocale::countryToString( m_locale.country() ) )
|
|
|
|
m_englishLabel = needsCountryName ? longFormat.arg( englishName, QLocale::countryToString( m_locale.country() ) )
|
|
|
|
: englishName;
|
|
|
|
: englishName;
|
|
|
|
|
|
|
|
emit englishLabelChanged(m_englishLabel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QLocale
|
|
|
|
QLocale
|
|
|
|