diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-06-24 10:15:16 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-06-24 09:22:42 +0000 |
commit | 1e589e37a991b29076e9a661f92dfa178421c208 (patch) | |
tree | ccdae70edb75b1bc17f0efc61086e16554e3f4eb /src/libs/installer/copydirectoryoperation.cpp | |
parent | 65a5d4d33c7dcb27ce99ce59535733a28991c544 (diff) |
Unify translated error messages
* Enclose file paths in ""
* Localize file paths with QDir::toNativeSeparators.
* Make sure sentences end with a '.'
* Append error details always by ':', e.g.
tr("Failed to copy file '%1': %2").(...)
* Use 'directory' instead of 'folder' everywhere
Change-Id: Ie045f429f72ad5045c96537465c5fb9d2e99d250
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/copydirectoryoperation.cpp')
-rw-r--r-- | src/libs/installer/copydirectoryoperation.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/libs/installer/copydirectoryoperation.cpp b/src/libs/installer/copydirectoryoperation.cpp index 06c952993..a25e00930 100644 --- a/src/libs/installer/copydirectoryoperation.cpp +++ b/src/libs/installer/copydirectoryoperation.cpp @@ -78,18 +78,21 @@ bool CopyDirectoryOperation::performOperation() } else { setError(InvalidArguments); setErrorString(tr("Invalid argument in %1: Third argument needs to be forceOverwrite, " - "if specified").arg(name())); + "if specified.").arg(name())); return false; } } const QFileInfo sourceInfo(sourcePath); const QFileInfo targetInfo(targetPath); - if (!sourceInfo.exists() || !sourceInfo.isDir() || !targetInfo.exists() || !targetInfo.isDir()) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %1: Directories are invalid: %2 %3").arg(name()) - .arg(sourcePath).arg(targetPath)); - return false; + + foreach (const QFileInfo &dir, QList<QFileInfo>() << sourceInfo << targetInfo) { + if (!dir.exists() || !dir.isDir()) { + setError(InvalidArguments); + setErrorString(tr("Invalid argument in %1: Directory \"%2\" is invalid.").arg(name()) + .arg(QDir::toNativeSeparators(sourcePath))); + return false; + } } const QDir sourceDir = sourceInfo.absoluteDir(); @@ -120,22 +123,24 @@ bool CopyDirectoryOperation::performOperation() } else if (itemInfo.isDir()) { if (!targetDir.mkpath(targetDir.absoluteFilePath(relativePath))) { setError(InvalidArguments); - setErrorString(tr("Could not create %1").arg(targetDir.absoluteFilePath(relativePath))); + setErrorString(tr("Cannot create directory \"%1\".").arg( + QDir::toNativeSeparators(targetDir.absoluteFilePath(relativePath)))); return false; } } else { const QString absolutePath = targetDir.absoluteFilePath(relativePath); if (overwrite && QFile::exists(absolutePath) && !deleteFileNowOrLater(absolutePath)) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1").arg(absolutePath)); + setErrorString(tr("Failed to overwrite \"%1\".").arg(QDir::toNativeSeparators(absolutePath))); return false; } QFile file(sourceDir.absoluteFilePath(itemName)); if (!file.copy(absolutePath)) { setError(UserDefinedError); - setErrorString(tr("Could not copy %1 to %2, error was: %3").arg(sourceDir.absoluteFilePath(itemName), - targetDir.absoluteFilePath(relativePath), - file.errorString())); + setErrorString(tr("Cannot copy file \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(sourceDir.absoluteFilePath(itemName)), + QDir::toNativeSeparators(targetDir.absoluteFilePath(relativePath)), + file.errorString())); return false; } autoPush.m_files.prepend(targetDir.absoluteFilePath(relativePath)); @@ -154,7 +159,7 @@ bool CopyDirectoryOperation::undoOperation() foreach (const QString &file, files) { if (!QFile::remove(file)) { setError(InvalidArguments); - setErrorString(tr("Could not remove %1").arg(file)); + setErrorString(tr("Cannot remove file \"%1\".").arg(QDir::toNativeSeparators(file))); return false; } dir.rmpath(QFileInfo(file).absolutePath()); |