diff --git a/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc b/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc index 665e97031bd..4a7d5435781 100644 --- a/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc +++ b/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc @@ -137,6 +137,10 @@ \li Use clean settings for debug or testing reasons. The settings will be deleted when \QC exits. + \row + \li -language + \li Set the UI language. + \row \li -test [,testfunction[:testdata]] ... \li For \QC plugin developers: run the plugin's tests using a diff --git a/src/app/main.cpp b/src/app/main.cpp index 48cdc283cf2..e197f17393a 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -67,18 +67,20 @@ using namespace ExtensionSystem; enum { OptionIndent = 4, DescriptionIndent = 34 }; const char corePluginNameC[] = "Core"; -const char fixedOptionsC[] = -" [OPTION]... [FILE]...\n" -"Options:\n" -" -help Display this help\n" -" -version Display program version\n" -" -client Attempt to connect to already running first instance\n" -" -settingspath Override the default path where user settings are stored\n" -" -installsettingspath Override the default path from where user-independent settings are read\n" -" -temporarycleansettings, -tcs Use clean settings for debug or testing reasons\n" -" -pid Attempt to connect to instance given by pid\n" -" -block Block until editor is closed\n" -" -pluginpath Add a custom search path for plugins\n"; +const char fixedOptionsC[] + = " [OPTION]... [FILE]...\n" + "Options:\n" + " -help Display this help\n" + " -version Display program version\n" + " -client Attempt to connect to already running first instance\n" + " -settingspath Override the default path where user settings are stored\n" + " -installsettingspath Override the default path from where user-independent " + "settings are read\n" + " -temporarycleansettings, -tcs Use clean settings for debug or testing reasons\n" + " -pid Attempt to connect to instance given by pid\n" + " -block Block until editor is closed\n" + " -pluginpath Add a custom search path for plugins\n" + " -language Set the UI language\n"; const char HELP_OPTION1[] = "-h"; const char HELP_OPTION2[] = "-help"; @@ -95,6 +97,7 @@ const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs"; const char PID_OPTION[] = "-pid"; const char BLOCK_OPTION[] = "-block"; const char PLUGINPATH_OPTION[] = "-pluginpath"; +const char LANGUAGE_OPTION[] = "-language"; const char USER_LIBRARY_PATH_OPTION[] = "-user-library-path"; // hidden option for qtcreator.sh using PluginSpecSet = QVector; @@ -305,6 +308,7 @@ struct Options QString settingsPath; QString installSettingsPath; QStringList customPluginPaths; + QString uiLanguage; // list of arguments that were handled and not passed to the application or plugin manager QStringList preAppArguments; // list of arguments to be passed to the application or plugin manager @@ -336,6 +340,10 @@ Options parseCommandLine(int argc, char *argv[]) ++it; options.customPluginPaths += QDir::fromNativeSeparators(nextArg); options.preAppArguments << arg << nextArg; + } else if (arg == LANGUAGE_OPTION && hasNext) { + ++it; + options.uiLanguage = nextArg; + options.preAppArguments << arg << nextArg; } else if (arg == USER_LIBRARY_PATH_OPTION && hasNext) { ++it; options.userLibraryPath = nextArg; @@ -597,6 +605,8 @@ int main(int argc, char **argv) QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString(); if (!overrideLanguage.isEmpty()) uiLanguages.prepend(overrideLanguage); + if (!options.uiLanguage.isEmpty()) + uiLanguages.prepend(options.uiLanguage); const QString &creatorTrPath = resourcePath() + "/translations"; for (QString locale : std::as_const(uiLanguages)) { locale = QLocale(locale).name();