[locale] Refactor to make updating global locale setting easier.

This commit is contained in:
Adriaan de Groot 2019-01-07 17:29:54 +01:00
parent e52f0318fe
commit 3ff480eaa9
2 changed files with 17 additions and 2 deletions

View file

@ -481,6 +481,16 @@ LocalePage::prettyLCLocale( const QString& lcLocale ) const
.arg( QLocale::countryToString( locale.country() ) );
}
void
LocalePage::updateGlobalLocale()
{
auto *gs = Calamares::JobQueue::instance()->globalStorage();
const QString bcp47 = m_selectedLocaleConfiguration.toBcp47();
gs->insert( "locale", bcp47 );
}
void
LocalePage::updateGlobalStorage()
{
@ -493,8 +503,7 @@ LocalePage::updateGlobalStorage()
gs->insert( "locationRegion", location.region );
gs->insert( "locationZone", location.zone );
const QString bcp47 = m_selectedLocaleConfiguration.toBcp47();
gs->insert( "locale", bcp47 );
updateGlobalLocale();
// If we're in chroot mode (normal install mode), then we immediately set the
// timezone on the live system. When debugging timezones, don't bother.

View file

@ -57,6 +57,12 @@ private:
// the settings for language and numbers.
std::pair< QString, QString > prettyLocaleStatus( const LocaleConfiguration& ) const;
/** @brief Update the GS *locale* key with the selected system language.
*
* This uses whatever is set in m_selectedLocaleConfiguration as the language,
* and writes it to GS *locale* key (as a string, in BCP47 format).
*/
void updateGlobalLocale();
void updateGlobalStorage();
void updateLocaleLabels();