tdf#173271 Make the --language option override the config

Previously if the user has configured a language preference in the
config then that choice took precedence over the --language option. It
seems like the --language option is intended for temporary testing of a
language so it would be more useful if it overrode the language choice
in the config.

Change-Id: I30d027b685b9fabda42f40c12599310dfbfc7cfa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209982
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
This commit is contained in:
Neil Roberts
2026-08-28 13:46:13 +02:00
parent b83f3eb2b1
commit 7fe6fc9210
2 changed files with 19 additions and 20 deletions
+2 -3
View File
@@ -107,9 +107,8 @@ namespace desktop
" or socket,host=localhost,port=54321;urp \n"
" --unaccept={connect-string} Closes an acceptor that was created with \n"
" --accept. Use --unaccept=all to close all acceptors. \n"
" --language={lang} Uses specified language, if language is not selected \n"
" yet for UI. The lang is a tag of the language in IETF \n"
" language tag. \n\n"
" --language={lang} Overrides the choice of language for the UI. The lang is\n"
" a tag of the language in IETF language tag. \n\n"
"Developer arguments: \n"
" --terminate_after_init \n"
" Exit after initialization complete (no documents loaded)\n"
+17 -17
View File
@@ -77,26 +77,26 @@ bool prepareLocale() {
setMsLangIdFallback(officecfg::System::L10N::Locale::get());
css::uno::Sequence<OUString> inst(
officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
OUString locale(officecfg::Office::Linguistic::General::UILocale::get());
if (!locale.isEmpty()) {
locale = getInstalledLocaleForLanguage(inst, locale);
if (locale.isEmpty()) {
// Selected language is not/no longer installed:
try {
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Linguistic::General::UILocale::set(
u""_ustr, batch);
batch->commit();
} catch (const css::uno::Exception &) {
TOOLS_WARN_EXCEPTION("desktop.app", "ignoring");
OUString locale = getInstalledLocaleForLanguage(
inst, Desktop::GetCommandLineArgs().GetLanguage());
if (locale.isEmpty()) {
locale = officecfg::Office::Linguistic::General::UILocale::get();
if (!locale.isEmpty()) {
locale = getInstalledLocaleForLanguage(inst, locale);
if (locale.isEmpty()) {
// Selected language is not/no longer installed:
try {
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Linguistic::General::UILocale::set(
u""_ustr, batch);
batch->commit();
} catch (const css::uno::Exception &) {
TOOLS_WARN_EXCEPTION("desktop.app", "ignoring");
}
}
}
}
if (locale.isEmpty()) {
locale = getInstalledLocaleForLanguage(
inst, Desktop::GetCommandLineArgs().GetLanguage());
}
if (locale.isEmpty()) {
locale = getInstalledLocaleForSystemUILanguage(inst, true);
}