Skip to content

Commit

Permalink
Remove command line option --language
Browse files Browse the repository at this point in the history
This option was used before the UI language could be chosen in the
settings.

Fixes: #11245

Todo: changelog entry
  • Loading branch information
erikjv committed Oct 9, 2023
1 parent 13700a1 commit fc8a078
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 40 deletions.
27 changes: 11 additions & 16 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,18 @@ void Application::setupTranslations()
qCDebug(lcApplication) << "UI languages:" << uiLanguages;

// the user can also set a locale in the settings, so we need to load the config file
ConfigFile cfg;
const ConfigFile cfg;

// we need to track the enforced languages separately, since we need to distinguish between locale-provided
// and user-enforced ones below
QSet<QString> enforcedLanguages;

// note that user-enforced languages are prioritized over the theme enforced one
// to make testing easier, --language overrides the setting from the config file
// as we are prepending to the list of languages, the list passed to the loop must be sorted with ascending priority
for (const auto &enforcedLocale : {cfg.uiLanguage(), _userEnforcedLanguage}) {
if (!enforcedLocale.isEmpty()) {
enforcedLanguages.insert(enforcedLocale);
uiLanguages.prepend(enforcedLocale);
}
}
// we need to track the enforced language separately, since we need to distinguish between locale-provided
// and user-enforced one below
const QString enforcedLocale = cfg.uiLanguage();
qCDebug(lcApplication) << "Enforced language:" << enforcedLocale;

qCDebug(lcApplication) << "Enforced languages:" << enforcedLanguages;
// note that user-enforced language are prioritized over the theme enforced one
// to make testing easier.
if (!enforcedLocale.isEmpty()) {
uiLanguages.prepend(enforcedLocale);
}

QTranslator *translator = new QTranslator(this);
QTranslator *qtTranslator = new QTranslator(this);
Expand Down Expand Up @@ -341,7 +336,7 @@ void Application::setupTranslations()
// not mess with the system locale, though
// if we did, we would enforce a locale for no apparent reason
// see https://github.com/owncloud/client/issues/8608 for more information
if (enforcedLanguages.contains(lang)) {
if (enforcedLocale == lang) {
QLocale newLocale(lang);
qCDebug(lcApplication) << "language" << lang << "was enforced, changing default locale to" << newLocale;
QLocale::setDefault(newLocale);
Expand Down
1 change: 0 additions & 1 deletion src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ protected slots:
QPointer<ownCloudGui> _gui = {};

const bool _debugMode = false;
QString _userEnforcedLanguage;
QString _displayLanguage;

static Application *_instance;
Expand Down
23 changes: 0 additions & 23 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ struct CommandLineOptions

bool debugMode = false;

QString userEnforcedLanguage;

QString fileToOpen;
};

Expand Down Expand Up @@ -128,8 +126,6 @@ CommandLineOptions parseOptions(const QStringList &arguments)
auto logDirOption = addOption({QStringLiteral("logdir"), QStringLiteral("Write each sync log output in a new file in folder."), QStringLiteral("name")});
auto logFlushOption = addOption({QStringLiteral("logflush"), QStringLiteral("Flush the log file after every write.")});
auto logDebugOption = addOption({QStringLiteral("logdebug"), QStringLiteral("Output debug-level messages in the log.")});
auto languageOption = addOption({QStringLiteral("language"), QStringLiteral("Override UI language."), QStringLiteral("language")});
auto listLanguagesOption = addOption({QStringLiteral("list-languages"), QStringLiteral("Lists available translations, see --language.")});
auto confDirOption = addOption({QStringLiteral("confdir"), QStringLiteral("Use the given configuration folder."), QStringLiteral("dirname")});
auto debugOption = addOption({QStringLiteral("debug"), QStringLiteral("Enable debug mode.")});
addOption({QStringLiteral("cmd"), QStringLiteral("Forward all arguments to the cmd client. This argument must be the first.")});
Expand Down Expand Up @@ -174,25 +170,6 @@ CommandLineOptions parseOptions(const QStringList &arguments)
out.logDebug = true;
out.debugMode = true;
}
if (parser.isSet(languageOption)) {
const auto languageValue = parser.value(languageOption);

// fail if the language is unknown
if (!Translations::listAvailableTranslations().contains(languageValue)) {
displayHelpText(
QStringLiteral("Error: unknown language \"%1\" (use --list-languages to get a complete list of supported translations)").arg(languageValue));
std::exit(1);
} else {
out.userEnforcedLanguage = languageValue;
}
}
if (parser.isSet(listLanguagesOption)) {
const auto translationSet = Translations::listAvailableTranslations();
auto availableTranslations = QStringList{translationSet.cbegin(), translationSet.cend()};
availableTranslations.sort(Qt::CaseInsensitive);
displayHelpText(QStringLiteral("Available translations: %1").arg(availableTranslations.join(QStringLiteral(", "))));
std::exit(1);
}

auto positionalArguments = parser.positionalArguments();

Expand Down

0 comments on commit fc8a078

Please sign in to comment.