[libcalamares] Add ${LANG} to process expansions

This commit is contained in:
Adriaan de Groot 2024-02-26 22:33:17 +01:00
parent 0f2bceb72f
commit 028e9e68f9
2 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "JobQueue.h" #include "JobQueue.h"
#include "compat/Variant.h" #include "compat/Variant.h"
#include "locale/Global.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/StringExpander.h" #include "utils/StringExpander.h"
#include "utils/System.h" #include "utils/System.h"
@ -77,6 +78,16 @@ get_gs_expander( System::RunLocation location )
expander.insert( QStringLiteral( "USER" ), gs->value( "username" ).toString() ); expander.insert( QStringLiteral( "USER" ), gs->value( "username" ).toString() );
} }
if ( gs )
{
const auto key = QStringLiteral( "LANG" );
const QString lang = Calamares::Locale::readGS( *gs, key );
if ( !lang.isEmpty() )
{
expander.insert( key, lang );
}
}
return expander; return expander;
} }
@ -106,7 +117,7 @@ CommandLine::expand( KMacroExpanderBase& expander ) const
// .. and expand in each environment key=value string. // .. and expand in each environment key=value string.
QStringList e = m_environment; QStringList e = m_environment;
std::for_each(e.begin(), e.end(), [&expander](QString & s) { expander.expandMacrosShellQuote(s);}); std::for_each( e.begin(), e.end(), [ &expander ]( QString& s ) { expander.expandMacrosShellQuote( s ); } );
return { c, m_environment, m_timeout }; return { c, m_environment, m_timeout };
} }

View File

@ -12,6 +12,9 @@
# system from the point of view of the command (when run in the target # system from the point of view of the command (when run in the target
# system, e.g. when *dontChroot* is false, that will be `/`). # system, e.g. when *dontChroot* is false, that will be `/`).
# - `USER` is replaced by the username, set on the user page. # - `USER` is replaced by the username, set on the user page.
# - `LANG` is replaced by the language chosen for the user-interface
# of Calamares, set on the welcome page. This may not reflect the
# chosen system language from the locale page.
# #
# Variables are written as `${var}`, e.g. `${ROOT}`. # Variables are written as `${var}`, e.g. `${ROOT}`.
# Write `$$` to get a shell-escaped `\$` in the shell command. # Write `$$` to get a shell-escaped `\$` in the shell command.