mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 10:55:37 -04:00
Allow passing a LOCALE variable in the package list
This allows for installing locale packages. This can be achieved by adding a entry of the format packagename-${LOCALE} in the packages configuration module.
This commit is contained in:
parent
39d188079c
commit
4a55802b18
4 changed files with 21 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LocaleConfiguration.h"
|
#include "LocaleConfiguration.h"
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
LocaleConfiguration::LocaleConfiguration()
|
LocaleConfiguration::LocaleConfiguration()
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
|
||||||
{
|
{
|
||||||
LocaleConfiguration lc = LocaleConfiguration();
|
LocaleConfiguration lc = LocaleConfiguration();
|
||||||
QString language = languageLocale.split( '_' ).first();
|
QString language = languageLocale.split( '_' ).first();
|
||||||
|
lc.myLanguageLocaleBcp47 = QLocale(language).bcp47Name();
|
||||||
|
|
||||||
QStringList linesForLanguage;
|
QStringList linesForLanguage;
|
||||||
for ( const QString &line : availableLocales )
|
for ( const QString &line : availableLocales )
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
// avoid confusion with locale.h.
|
// avoid confusion with locale.h.
|
||||||
QString lang, lc_numeric, lc_time, lc_monetary, lc_paper, lc_name, lc_address,
|
QString lang, lc_numeric, lc_time, lc_monetary, lc_paper, lc_name, lc_address,
|
||||||
lc_telephone, lc_measurement, lc_identification;
|
lc_telephone, lc_measurement, lc_identification;
|
||||||
|
QString myLanguageLocaleBcp47;
|
||||||
QMap< QString, QString > toMap();
|
QMap< QString, QString > toMap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -474,6 +474,8 @@ LocalePage::updateGlobalStorage()
|
||||||
->insert( "locationRegion", location.region );
|
->insert( "locationRegion", location.region );
|
||||||
Calamares::JobQueue::instance()->globalStorage()
|
Calamares::JobQueue::instance()->globalStorage()
|
||||||
->insert( "locationZone", location.zone );
|
->insert( "locationZone", location.zone );
|
||||||
|
Calamares::JobQueue::instance()->globalStorage()
|
||||||
|
->insert( "locale", m_selectedLocaleConfiguration.myLanguageLocaleBcp47);
|
||||||
|
|
||||||
// If we're in chroot mode (normal install mode), then we immediately set the
|
// If we're in chroot mode (normal install mode), then we immediately set the
|
||||||
// timezone on the live system.
|
// timezone on the live system.
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import libcalamares
|
import libcalamares
|
||||||
from libcalamares.utils import check_target_env_call, target_env_call
|
from libcalamares.utils import check_target_env_call, target_env_call
|
||||||
|
from string import Template
|
||||||
|
|
||||||
class PackageManager:
|
class PackageManager:
|
||||||
""" Package manager class.
|
""" Package manager class.
|
||||||
|
@ -109,6 +109,20 @@ class PackageManager:
|
||||||
check_target_env_call(["equo", "update"])
|
check_target_env_call(["equo", "update"])
|
||||||
|
|
||||||
|
|
||||||
|
def subst_locale(list):
|
||||||
|
ret = []
|
||||||
|
locale = libcalamares.globalstorage.value("locale")
|
||||||
|
if locale:
|
||||||
|
for e in list:
|
||||||
|
if locale != "en":
|
||||||
|
entry = Template(e)
|
||||||
|
ret.append(entry.safe_substitute(LOCALE=locale))
|
||||||
|
elif 'LOCALE' not in e:
|
||||||
|
ret.append(e)
|
||||||
|
else:
|
||||||
|
ret = list
|
||||||
|
return ret
|
||||||
|
|
||||||
def run_operations(pkgman, entry):
|
def run_operations(pkgman, entry):
|
||||||
""" Call package manager with given parameters.
|
""" Call package manager with given parameters.
|
||||||
|
|
||||||
|
@ -116,6 +130,7 @@ def run_operations(pkgman, entry):
|
||||||
:param entry:
|
:param entry:
|
||||||
"""
|
"""
|
||||||
for key in entry.keys():
|
for key in entry.keys():
|
||||||
|
entry[key] = subst_locale(entry[key])
|
||||||
if key == "install":
|
if key == "install":
|
||||||
pkgman.install(entry[key])
|
pkgman.install(entry[key])
|
||||||
elif key == "try_install":
|
elif key == "try_install":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue