forked from qt-creator/qt-creator
Do not use tr() in cpaster-frontend.
The command-line tool does not load any translations. Prevent the messages from showing up in Qt Creator's ts-files. Change-Id: I25e9cffb6fcd35fae7b021c2eb7ec60480db868d Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "argumentscollector.h"
|
#include "argumentscollector.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
static QString pasteRequestString() { return QLatin1String("paste"); }
|
static QString pasteRequestString() { return QLatin1String("paste"); }
|
||||||
static QString listProtocolsRequestString() { return QLatin1String("list-protocols"); }
|
static QString listProtocolsRequestString() { return QLatin1String("list-protocols"); }
|
||||||
@@ -69,25 +70,20 @@ bool ArgumentsCollector::collect(const QStringList &args)
|
|||||||
|
|
||||||
QString ArgumentsCollector::usageString() const
|
QString ArgumentsCollector::usageString() const
|
||||||
{
|
{
|
||||||
QString usage = tr("Usage:");
|
QString usage = QString::fromLatin1("Usage:\n\t%1 <request> [ <request options>]\n\t")
|
||||||
usage += QLatin1String("\n\t");
|
|
||||||
usage += tr("%1 <request> [ <request options>]")
|
|
||||||
.arg(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
|
.arg(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
|
||||||
usage += QLatin1String("\n\t");
|
usage += QString::fromLatin1("Possible requests: \"%1\", \"%2\", \"%3\"\n\t")
|
||||||
usage += tr("Possible requests: \"%1\", \"%2\", \"%3\"")
|
|
||||||
.arg(pasteRequestString(), listProtocolsRequestString(), helpRequestString());
|
.arg(pasteRequestString(), listProtocolsRequestString(), helpRequestString());
|
||||||
usage += QLatin1String("\n\t");
|
usage += QString::fromLatin1("Possible options for request \"%1\": \"%2 <file>\" (default: stdin), "
|
||||||
usage += tr("Possible options for request \"%1\": \"%2 <file>\" (default: stdin), "
|
"\"%3 <protocol>\"\n")
|
||||||
"\"%3 <protocol>\"")
|
|
||||||
.arg(pasteRequestString(), pasteFileOptionString(), pasteProtocolOptionString());
|
.arg(pasteRequestString(), pasteFileOptionString(), pasteProtocolOptionString());
|
||||||
usage += QLatin1Char('\n');
|
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgumentsCollector::setRequest()
|
void ArgumentsCollector::setRequest()
|
||||||
{
|
{
|
||||||
if (m_arguments.isEmpty())
|
if (m_arguments.isEmpty())
|
||||||
throw ArgumentErrorException(tr("No request given"));
|
throw ArgumentErrorException(QLatin1String("No request given"));
|
||||||
const QString requestString = m_arguments.takeFirst();
|
const QString requestString = m_arguments.takeFirst();
|
||||||
if (requestString == pasteRequestString())
|
if (requestString == pasteRequestString())
|
||||||
m_requestType = RequestTypePaste;
|
m_requestType = RequestTypePaste;
|
||||||
@@ -96,7 +92,7 @@ void ArgumentsCollector::setRequest()
|
|||||||
else if (requestString == helpRequestString())
|
else if (requestString == helpRequestString())
|
||||||
m_requestType = RequestTypeHelp;
|
m_requestType = RequestTypeHelp;
|
||||||
else
|
else
|
||||||
throw ArgumentErrorException(tr("Unknown request \"%1\"").arg(requestString));
|
throw ArgumentErrorException(QString::fromLatin1("Unknown request \"%1\"").arg(requestString));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgumentsCollector::setPasteOptions()
|
void ArgumentsCollector::setPasteOptions()
|
||||||
@@ -106,15 +102,15 @@ void ArgumentsCollector::setPasteOptions()
|
|||||||
continue;
|
continue;
|
||||||
if (checkAndSetOption(pasteProtocolOptionString(), m_protocol)) {
|
if (checkAndSetOption(pasteProtocolOptionString(), m_protocol)) {
|
||||||
if (!m_availableProtocols.contains(m_protocol))
|
if (!m_availableProtocols.contains(m_protocol))
|
||||||
throw ArgumentErrorException(tr("Unknown protocol \"%1\"").arg(m_protocol));
|
throw ArgumentErrorException(QString::fromLatin1("Unknown protocol \"%1\"").arg(m_protocol));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
throw ArgumentErrorException(tr("Invalid option \"%1\" for request \"%2\"")
|
throw ArgumentErrorException(QString::fromLatin1("Invalid option \"%1\" for request \"%2\"")
|
||||||
.arg(m_arguments.first(), pasteRequestString()));
|
.arg(m_arguments.first(), pasteRequestString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_protocol.isEmpty())
|
if (m_protocol.isEmpty())
|
||||||
throw ArgumentErrorException(tr("No protocol given"));
|
throw ArgumentErrorException(QLatin1String("No protocol given"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArgumentsCollector::checkAndSetOption(const QString &optionString, QString &optionValue)
|
bool ArgumentsCollector::checkAndSetOption(const QString &optionString, QString &optionValue)
|
||||||
@@ -123,10 +119,10 @@ bool ArgumentsCollector::checkAndSetOption(const QString &optionString, QString
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!optionValue.isEmpty())
|
if (!optionValue.isEmpty())
|
||||||
throw ArgumentErrorException(tr("option \"%1\" was given twice").arg(optionString));
|
throw ArgumentErrorException(QString::fromLatin1("option \"%1\" was given twice").arg(optionString));
|
||||||
m_arguments.removeFirst();
|
m_arguments.removeFirst();
|
||||||
if (m_arguments.isEmpty()) {
|
if (m_arguments.isEmpty()) {
|
||||||
throw ArgumentErrorException(tr("Option \"%1\" requires an argument")
|
throw ArgumentErrorException(QString::fromLatin1("Option \"%1\" requires an argument")
|
||||||
.arg(optionString));
|
.arg(optionString));
|
||||||
}
|
}
|
||||||
optionValue = m_arguments.takeFirst();
|
optionValue = m_arguments.takeFirst();
|
||||||
|
|||||||
@@ -30,12 +30,10 @@
|
|||||||
#ifndef ARGUMENTSCOLLECTOR_H
|
#ifndef ARGUMENTSCOLLECTOR_H
|
||||||
#define ARGUMENTSCOLLECTOR_H
|
#define ARGUMENTSCOLLECTOR_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
class ArgumentsCollector
|
class ArgumentsCollector
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(ArgumentsCollector)
|
|
||||||
public:
|
public:
|
||||||
ArgumentsCollector(const QStringList &availableProtocols);
|
ArgumentsCollector(const QStringList &availableProtocols);
|
||||||
bool collect(const QStringList &args); // Application is already removed.
|
bool collect(const QStringList &args); // Application is already removed.
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
Reference in New Issue
Block a user