Translations: Fix stray QApplication::translate() calls

For references to the module-own context, use Tr::tr().
For references to other modules, use the right context name (with "::"
prefix).

Change-Id: I6dce8f1ceccb23c44d93f1826402cd3be8e98e5a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2023-02-07 22:46:35 +01:00
parent 2356f28647
commit 9db70d8810
15 changed files with 26 additions and 31 deletions

View File

@@ -952,7 +952,7 @@ namespace ADS
const bool success = write(workspace, data, &errorString); const bool success = write(workspace, data, &errorString);
if (!success) if (!success)
QMessageBox::critical(parent, QMessageBox::critical(parent,
QCoreApplication::translate("Utils::FileSaverBase", "File Error"), QCoreApplication::translate("::Utils", "File Error"),
errorString); errorString);
return success; return success;
} }

View File

@@ -121,8 +121,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangDiagnostic &diagnostic)
// Create copy if needed // Create copy if needed
if (config.isReadOnly()) { if (config.isReadOnly()) {
const QString name = QCoreApplication::translate("ClangDiagnosticConfig", const QString name = Tr::tr("Project: %1 (based on %2)")
"Project: %1 (based on %2)")
.arg(project->displayName(), config.displayName()); .arg(project->displayName(), config.displayName());
config = ClangDiagnosticConfigsModel::createCustomConfig(config, name); config = ClangDiagnosticConfigsModel::createCustomConfig(config, name);
} }
@@ -141,9 +140,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangDiagnostic &diagnostic)
projectSettings.setDiagnosticConfigId(config.id()); projectSettings.setDiagnosticConfigId(config.id());
// Notify the user about changed project specific settings // Notify the user about changed project specific settings
const QString text const QString text = Tr::tr("Changes applied in Projects Mode > Clang Code Model");
= QCoreApplication::translate("ClangDiagnosticConfig",
"Changes applied in Projects Mode > Clang Code Model");
FadingIndicator::showText(Core::ICore::mainWindow(), FadingIndicator::showText(Core::ICore::mainWindow(),
text, text,
FadingIndicator::SmallText); FadingIndicator::SmallText);

View File

@@ -154,15 +154,14 @@ GenerateCompilationDbResult generateCompilationDB(QList<ProjectInfo::ConstPtr> p
FilePath clangIncludeDir) FilePath clangIncludeDir)
{ {
QTC_ASSERT(!baseDir.isEmpty(), return GenerateCompilationDbResult(QString(), QTC_ASSERT(!baseDir.isEmpty(), return GenerateCompilationDbResult(QString(),
QCoreApplication::translate("ClangUtils", "Could not retrieve build directory."))); Tr::tr("Could not retrieve build directory.")));
QTC_ASSERT(!projectInfoList.isEmpty(), QTC_ASSERT(!projectInfoList.isEmpty(),
return GenerateCompilationDbResult(QString(), "Could not retrieve project info.")); return GenerateCompilationDbResult(QString(), "Could not retrieve project info."));
QTC_CHECK(baseDir.ensureWritableDir()); QTC_CHECK(baseDir.ensureWritableDir());
QFile compileCommandsFile(baseDir.pathAppended("compile_commands.json").toFSPathString()); QFile compileCommandsFile(baseDir.pathAppended("compile_commands.json").toFSPathString());
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate); const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
if (!fileOpened) { if (!fileOpened) {
return GenerateCompilationDbResult(QString(), return GenerateCompilationDbResult(QString(), Tr::tr("Could not create \"%1\": %2")
QCoreApplication::translate("ClangUtils", "Could not create \"%1\": %2")
.arg(compileCommandsFile.fileName(), compileCommandsFile.errorString())); .arg(compileCommandsFile.fileName(), compileCommandsFile.errorString()));
} }
compileCommandsFile.write("["); compileCommandsFile.write("[");

View File

@@ -116,7 +116,7 @@ ClangToolsOptionsPage::ClangToolsOptionsPage()
setId(Constants::SETTINGS_PAGE_ID); setId(Constants::SETTINGS_PAGE_ID);
setDisplayName(Tr::tr("Clang Tools")); setDisplayName(Tr::tr("Clang Tools"));
setCategory("T.Analyzer"); setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer")); setDisplayCategory(QCoreApplication::translate("::Debugger", "Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setWidgetCreator([] { return new SettingsWidget; }); setWidgetCreator([] { return new SettingsWidget; });
} }

View File

@@ -246,7 +246,7 @@ bool CMakeBuildStep::init()
RunConfiguration *rc = target()->activeRunConfiguration(); RunConfiguration *rc = target()->activeRunConfiguration();
if (!rc || rc->buildKey().isEmpty()) { if (!rc || rc->buildKey().isEmpty()) {
emit addTask(BuildSystemTask(Task::Error, emit addTask(BuildSystemTask(Task::Error,
QCoreApplication::translate("ProjectExplorer::Task", QCoreApplication::translate("::ProjectExplorer",
"You asked to build the current Run Configuration's build target only, " "You asked to build the current Run Configuration's build target only, "
"but it is not associated with a build target. " "but it is not associated with a build target. "
"Update the Make Step in your build settings."))); "Update the Make Step in your build settings.")));

View File

@@ -181,7 +181,7 @@ void CMakeProjectPlugin::initialize()
}); });
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::CMAKEFORMATTER_MENU_ID); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::CMAKEFORMATTER_MENU_ID);
menu->menu()->setTitle(QCoreApplication::translate("CMakeFormatter", "CMakeFormatter")); menu->menu()->setTitle(Tr::tr("CMakeFormatter"));
menu->setOnAllDisabledBehavior(Core::ActionContainer::Show); menu->setOnAllDisabledBehavior(Core::ActionContainer::Show);
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);

View File

@@ -126,7 +126,7 @@ CppcheckOptionsPage::CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &tr
setId(Constants::OPTIONS_PAGE_ID); setId(Constants::OPTIONS_PAGE_ID);
setDisplayName(Tr::tr("Cppcheck")); setDisplayName(Tr::tr("Cppcheck"));
setCategory("T.Analyzer"); setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer")); setDisplayCategory(QCoreApplication::translate("::Debugger", "Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
CppcheckOptions options; CppcheckOptions options;

View File

@@ -5077,7 +5077,7 @@ void GdbEngine::handleFetchVariables(const DebuggerResponse &response)
QString GdbEngine::msgPtraceError(DebuggerStartMode sm) QString GdbEngine::msgPtraceError(DebuggerStartMode sm)
{ {
if (sm == StartInternal) { if (sm == StartInternal) {
return QCoreApplication::translate("QtDumperHelper", return Tr::tr(
"ptrace: Operation not permitted.\n\n" "ptrace: Operation not permitted.\n\n"
"Could not attach to the process. " "Could not attach to the process. "
"Make sure no other debugger traces this process.\n" "Make sure no other debugger traces this process.\n"
@@ -5085,7 +5085,7 @@ QString GdbEngine::msgPtraceError(DebuggerStartMode sm)
"/proc/sys/kernel/yama/ptrace_scope\n" "/proc/sys/kernel/yama/ptrace_scope\n"
"For more details, see /etc/sysctl.d/10-ptrace.conf\n"); "For more details, see /etc/sysctl.d/10-ptrace.conf\n");
} }
return QCoreApplication::translate("QtDumperHelper", return Tr::tr(
"ptrace: Operation not permitted.\n\n" "ptrace: Operation not permitted.\n\n"
"Could not attach to the process. " "Could not attach to the process. "
"Make sure no other debugger traces this process.\n" "Make sure no other debugger traces this process.\n"

View File

@@ -1079,7 +1079,7 @@ void QmlEnginePrivate::updateScriptSource(const QString &fileName, int lineOffse
} }
//update open editors //update open editors
QString titlePattern = QCoreApplication::translate("QmlEngine", "JS Source for %1").arg(fileName); QString titlePattern = Tr::tr("JS Source for %1").arg(fileName);
//Check if there are open editors with the same title //Check if there are open editors with the same title
const QList<IDocument *> documents = DocumentModel::openedDocuments(); const QList<IDocument *> documents = DocumentModel::openedDocuments();
for (IDocument *doc: documents) { for (IDocument *doc: documents) {
@@ -2044,7 +2044,7 @@ StackFrame QmlEnginePrivate::extractStackFrame(const QVariant &bodyVal)
stackFrame.function = extractString(body.value("func")); stackFrame.function = extractString(body.value("func"));
if (stackFrame.function.isEmpty()) if (stackFrame.function.isEmpty())
stackFrame.function = QCoreApplication::translate("QmlEngine", "Anonymous Function"); stackFrame.function = Tr::tr("Anonymous Function");
stackFrame.file = FilePath::fromString( stackFrame.file = FilePath::fromString(
engine->toFileInProject(extractString(body.value("script")))); engine->toFileInProject(extractString(body.value("script"))));
stackFrame.usable = stackFrame.file.isReadableFile(); stackFrame.usable = stackFrame.file.isReadableFile();

View File

@@ -46,7 +46,7 @@ bool FormPageFactory::validateData(Utils::Id typeId, const QVariant &data, QStri
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) { if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", *errorMessage = QCoreApplication::translate("::ProjectExplorer",
"\"data\" for a \"Form\" page needs to be unset or an empty object."); "\"data\" for a \"Form\" page needs to be unset or an empty object.");
return false; return false;
} }

View File

@@ -281,10 +281,8 @@ bool GerritServer::resolveRoot()
case CertificateError: case CertificateError:
if (QMessageBox::question( if (QMessageBox::question(
Core::ICore::dialogParent(), Core::ICore::dialogParent(),
QCoreApplication::translate( Tr::tr("Certificate Error"),
"Gerrit::Internal::GerritDialog", "Certificate Error"), Tr::tr(
QCoreApplication::translate(
"Gerrit::Internal::GerritDialog",
"Server certificate for %1 cannot be authenticated.\n" "Server certificate for %1 cannot be authenticated.\n"
"Do you want to disable SSL verification for this server?\n" "Do you want to disable SSL verification for this server?\n"
"Note: This can expose you to man-in-the-middle attack.") "Note: This can expose you to man-in-the-middle attack.")

View File

@@ -16,7 +16,7 @@ PerfOptionsPage::PerfOptionsPage(PerfSettings *settings)
setId(Constants::PerfSettingsId); setId(Constants::PerfSettingsId);
setDisplayName(Tr::tr("CPU Usage")); setDisplayName(Tr::tr("CPU Usage"));
setCategory("T.Analyzer"); setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer")); setDisplayCategory(QCoreApplication::translate("::Debugger", "Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setWidgetCreator([settings] { return new PerfConfigWidget(settings); }); setWidgetCreator([settings] { return new PerfConfigWidget(settings); });
} }

View File

@@ -4,6 +4,7 @@
#include "extraabi.h" #include "extraabi.h"
#include "abi.h" #include "abi.h"
#include "projectexplorertr.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -39,8 +40,7 @@ public:
}; };
AbiFlavorAccessor::AbiFlavorAccessor() : AbiFlavorAccessor::AbiFlavorAccessor() :
UpgradingSettingsAccessor("QtCreatorExtraAbi", UpgradingSettingsAccessor("QtCreatorExtraAbi", Tr::tr("ABI")
QCoreApplication::translate("ProjectExplorer::ToolChainManager", "ABI"),
Core::Constants::IDE_DISPLAY_NAME) Core::Constants::IDE_DISPLAY_NAME)
{ {
setBaseFilePath(Core::ICore::installerResourcePath("abi.xml")); setBaseFilePath(Core::ICore::installerResourcePath("abi.xml"));

View File

@@ -3,6 +3,8 @@
#include "profilereader.h" #include "profilereader.h"
#include "qtsupporttr.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
@@ -26,7 +28,7 @@ ProMessageHandler::ProMessageHandler(bool verbose, bool exact)
: m_verbose(verbose) : m_verbose(verbose)
, m_exact(exact) , m_exact(exact)
//: Prefix used for output from the cumulative evaluation of project files. //: Prefix used for output from the cumulative evaluation of project files.
, m_prefix(QCoreApplication::translate("ProMessageHandler", "[Inexact] ")) , m_prefix(Tr::tr("[Inexact] "))
{ {
} }

View File

@@ -2,7 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "resourcenode.h" #include "resourcenode.h"
#include "resourceeditorconstants.h" #include "resourceeditorconstants.h"
#include "resourceeditortr.h"
#include "qrceditor/resourcefile_p.h" #include "qrceditor/resourcefile_p.h"
#include <coreplugin/documentmanager.h> #include <coreplugin/documentmanager.h>
@@ -433,9 +435,7 @@ bool ResourceTopLevelNode::removeNonExistingFiles()
FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const FilePaths &files, Node *context) const FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2") const QString name = Tr::tr("%1 Prefix: %2").arg(filePath().fileName()).arg(QLatin1Char('/'));
.arg(filePath().fileName())
.arg(QLatin1Char('/'));
int p = getPriorityFromContextNode(this, context); int p = getPriorityFromContextNode(this, context);
if (p == -1 && hasPriority(files)) { // images/* and qml/js mimetypes if (p == -1 && hasPriority(files)) { // images/* and qml/js mimetypes
@@ -574,8 +574,7 @@ bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang
FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const FilePaths &files, Node *context) const FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2") const QString name = Tr::tr("%1 Prefix: %2").arg(m_topLevelNode->filePath().fileName())
.arg(m_topLevelNode->filePath().fileName())
.arg(displayName()); .arg(displayName());
int p = getPriorityFromContextNode(this, context); int p = getPriorityFromContextNode(this, context);