Skip to content

Commit

Permalink
Make command-line options and messages translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjv committed Oct 18, 2023
1 parent 53acaac commit 42a5a00
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
10 changes: 10 additions & 0 deletions changelog/unreleased/11300
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Change: Make messages translatable that occur early in start-up

These messages include the command-line messages (both errors and the
help text). To do this, the deprecated `--confdir` option has been
removed. This option was only used on windows before roaming profiles
were supported.

https://github.com/owncloud/client/issues/11142
https://github.com/owncloud/client/issues/11246
https://github.com/owncloud/client/pull/11300
32 changes: 17 additions & 15 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ CommandLineOptions parseOptions(const QStringList &arguments)
QString descriptionText;
QTextStream descriptionTextStream(&descriptionText);

descriptionTextStream
<< QStringLiteral("%1 version %2\r\nFile synchronization desktop utility.").arg(Theme::instance()->appName(), OCC::Version::displayString())
<< Qt::endl;
descriptionTextStream << QApplication::translate("CommandLine", "%1 version %2\r\nFile synchronization desktop utility.")
.arg(Theme::instance()->appName(), OCC::Version::displayString())
<< Qt::endl;

if (Theme::instance()->appName() == QLatin1String("ownCloud")) {
descriptionTextStream
Expand All @@ -116,24 +116,26 @@ CommandLineOptions parseOptions(const QStringList &arguments)
return option;
};

auto showSettingsLegacyOption = QCommandLineOption{{QStringLiteral("showsettings")}, QStringLiteral("Hidden legacy option")};
auto showSettingsLegacyOption = QCommandLineOption{{QStringLiteral("showsettings")}, QApplication::translate("CommandLine", "Hidden legacy option")};
showSettingsLegacyOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(showSettingsLegacyOption);

auto showOption = addOption({{QStringLiteral("s"), QStringLiteral("show")},
QStringLiteral(
QApplication::translate("CommandLine",
"Start with the main window visible, or if it is already running, bring it to the front. By default, the client launches in the background.")});
auto quitInstanceOption = addOption({{QStringLiteral("q"), QStringLiteral("quit")}, QStringLiteral("Quit the running instance.")});
auto logFileOption = addOption({QStringLiteral("logfile"), QStringLiteral("Write log to file (use - to write to stdout)."), QStringLiteral("filename")});
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 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.")});
auto quitInstanceOption = addOption({{QStringLiteral("q"), QStringLiteral("quit")}, QApplication::translate("CommandLine", "Quit the running instance.")});
auto logFileOption = addOption(
{QStringLiteral("logfile"), QApplication::translate("CommandLine", "Write log to file (use - to write to stdout)."), QStringLiteral("filename")});
auto logDirOption = addOption(
{QStringLiteral("logdir"), QApplication::translate("CommandLine", "Write each sync log output in a new file in folder."), QStringLiteral("name")});
auto logFlushOption = addOption({QStringLiteral("logflush"), QApplication::translate("CommandLine", "Flush the log file after every write.")});
auto logDebugOption = addOption({QStringLiteral("logdebug"), QApplication::translate("CommandLine", "Output debug-level messages in the log.")});
auto debugOption = addOption({QStringLiteral("debug"), QApplication::translate("CommandLine", "Enable debug mode.")});
addOption({QStringLiteral("cmd"), QApplication::translate("CommandLine", "Forward all arguments to the cmd client. This argument must be the first.")});

// virtual file system parameters (optional)
parser.addPositionalArgument(
QStringLiteral("vfs file"), QStringLiteral("Virtual file system file to be opened (optional)."), {QStringLiteral("[<vfs file>]")});
parser.addPositionalArgument(QStringLiteral("vfs file"), QApplication::translate("CommandLine", "Virtual file system file to be opened (optional)."),
{QStringLiteral("[<vfs file>]")});

parser.process(arguments);

Expand All @@ -149,7 +151,7 @@ CommandLineOptions parseOptions(const QStringList &arguments)
}
if (parser.isSet(logDirOption)) {
if (parser.isSet(logFileOption)) {
displayHelpText(QStringLiteral("--logfile and --logdir are mutually exclusive"));
displayHelpText(QApplication::translate("CommandLine", "--logfile and --logdir are mutually exclusive"));
std::exit(1);
}
out.logDir = parser.value(logDirOption);
Expand Down

0 comments on commit 42a5a00

Please sign in to comment.