From f52b5f87cf21c9cd8dea4ff1fad8fe5a32dbae80 Mon Sep 17 00:00:00 2001
From: Pavol Babincak <scroolik@gmail.com>
Date: Tue, 24 Apr 2012 20:18:18 +0200
Subject: File transfer strings made translatable

License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 4352c8b..3f16071 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -185,9 +185,9 @@ void ChatController::handleSettingChanged(const std::string& settingPath) {
 
 void ChatController::checkForDisplayingDisplayReceiptsAlert() {
 	if (userWantsReceipts_ && (contactSupportsReceipts_ == ChatWindow::No)) {
-		chatWindow_->setAlert("This chat doesn't support delivery receipts.");
+		chatWindow_->setAlert(QT_TRANSLATE_NOOP("", "This chat doesn't support delivery receipts."));
 	} else if (userWantsReceipts_ && (contactSupportsReceipts_ == ChatWindow::Maybe)) {
-		chatWindow_->setAlert("This chat may not support delivery receipts. You might not receive delivery receipts for the messages you sent.");
+		chatWindow_->setAlert(QT_TRANSLATE_NOOP("", "This chat may not support delivery receipts. You might not receive delivery receipts for the messages you sent."));
 	} else {
 		chatWindow_->cancelAlert();
 	}
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp
index a25dfe6..3feaf49 100644
--- a/Swift/Controllers/FileTransfer/FileTransferController.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp
@@ -12,6 +12,7 @@
 #include <boost/bind.hpp>
 #include "Swift/Controllers/UIInterfaces/ChatWindow.h"
 #include <Swiften/Base/Log.h>
+#include <Swift/Controllers/Intl.h>
 
 #include <boost/smart_ptr/make_shared.hpp>
 
@@ -38,7 +39,7 @@ const JID &FileTransferController::getOtherParty() const {
 std::string FileTransferController::setChatWindow(ChatWindow* wnd, std::string nickname) {
 	chatWindow = wnd;
 	if (sending) {
-		uiID = wnd->addFileTransfer("me", true, filename, boost::filesystem::file_size(boost::filesystem::path(filename)));
+		uiID = wnd->addFileTransfer(QT_TRANSLATE_NOOP("", "me"), true, filename, boost::filesystem::file_size(boost::filesystem::path(filename)));
 	} else {
 		uiID = wnd->addFileTransfer(nickname, false, filename, transfer->fileSizeInBytes);
 	}
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 4fa25ee..e1d718f 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -327,12 +327,12 @@ void QtChatView::setFileTransferStatus(QString id, const ChatWindow::FileTransfe
 
 	QString newInnerHTML = "";
 	if (state == ChatWindow::WaitingForAccept) {
-		newInnerHTML =	"Waiting for other side to accept the transfer.<br/>" +
+		newInnerHTML =	tr("Waiting for other side to accept the transfer.") + "<br/>" +
 			QtChatWindow::buildChatWindowButton(tr("Cancel"), QtChatWindow::ButtonFileTransferCancel, id);
 	}
 	if (state == ChatWindow::Negotiating) {
 		// replace with text "Negotiaging" + Cancel button
-		newInnerHTML =	"Negotiating...<br/>" +
+		newInnerHTML =	tr("Negotiating...") + "<br/>" +
 			QtChatWindow::buildChatWindowButton(tr("Cancel"), QtChatWindow::ButtonFileTransferCancel, id);
 	}
 	else if (state == ChatWindow::Transferring) {
@@ -347,14 +347,14 @@ void QtChatView::setFileTransferStatus(QString id, const ChatWindow::FileTransfe
 						QtChatWindow::buildChatWindowButton(tr("Cancel"), QtChatWindow::ButtonFileTransferCancel, id);
 	}
 	else if (state == ChatWindow::Canceled) {
-		newInnerHTML = "Transfer has been canceled!";
+		newInnerHTML = tr("Transfer has been canceled!");
 	}
 	else if (state == ChatWindow::Finished) {
 		// text "Successful transfer"
-		newInnerHTML = "Transfer completed successfully.";
+		newInnerHTML = tr("Transfer completed successfully.");
 	}
 	else if (state == ChatWindow::FTFailed) {
-		newInnerHTML = "Transfer failed.";
+		newInnerHTML = tr("Transfer failed.");
 	}
 
 	ftElement.setInnerXml(newInnerHTML);
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 5680996..28e6c36 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -545,7 +545,7 @@ std::string QtChatWindow::addFileTransfer(const std::string& senderName, bool se
 			"</div>";
 	} else {
 		// incoming
-		htmlString = "Receiving file: " + P2QSTRING(filename) + " ( " + formattedFileSize  + ") <br/>" +
+		htmlString = tr("Receiving file") + ": " + P2QSTRING(filename) + " ( " + formattedFileSize  + ") <br/>" +
 			"<div id='" + ft_id + "'>" +
 				buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, ft_id) +
 				buildChatWindowButton(tr("Accept"), ButtonFileTransferAcceptRequest, ft_id, P2QSTRING(filename)) +
diff --git a/Swift/QtUI/QtFileTransferListItemModel.cpp b/Swift/QtUI/QtFileTransferListItemModel.cpp
index 63dd45a..cf1de07 100644
--- a/Swift/QtUI/QtFileTransferListItemModel.cpp
+++ b/Swift/QtUI/QtFileTransferListItemModel.cpp
@@ -43,11 +43,11 @@ void QtFileTransferListItemModel::handleProgressChange(int index) {
 
 QVariant QtFileTransferListItemModel::headerData(int section, Qt::Orientation /* orientation */, int role) const {
 	if (role != Qt::DisplayRole) return QVariant();
-	if (section == Direction) return QVariant("Direction");
-	if (section == OtherParty) return QVariant("Other Party");
-	if (section == State) return QVariant("State");
-	if (section == Progress) return QVariant("Progress");
-	if (section == OverallSize) return QVariant("Size");
+	if (section == Direction) return QVariant(QObject::tr("Direction"));
+	if (section == OtherParty) return QVariant(QObject::tr("Other Party"));
+	if (section == State) return QVariant(QObject::tr("State"));
+	if (section == Progress) return QVariant(QObject::tr("Progress"));
+	if (section == OverallSize) return QVariant(QObject::tr("Size"));
 	return QVariant();
 }
 
@@ -62,7 +62,7 @@ QVariant QtFileTransferListItemModel::data(const QModelIndex &index, int role) c
 	}
 	FileTransferController* controller = fileTransferOverview->getFileTransfers().at(index.row());
 	if (index.column() == Direction) {
-		return controller->isIncoming() ? QVariant("Incoming") : QVariant("Outgoing");
+		return controller->isIncoming() ? QVariant(QObject::tr("Incoming")) : QVariant(QObject::tr("Outgoing"));
 	}
 	if (index.column() == OtherParty) {
 		return QVariant(QString::fromStdString(controller->getOtherParty().toString()));
@@ -71,19 +71,19 @@ QVariant QtFileTransferListItemModel::data(const QModelIndex &index, int role) c
 		FileTransfer::State state = controller->getState();
 		switch(state.state) {
 			case FileTransfer::State::WaitingForStart:
-				return QVariant("Waiting for start");
+				return QVariant(QObject::tr("Waiting for start"));
 			case FileTransfer::State::WaitingForAccept:
-				return QVariant("Waiting for other side to accept");
+				return QVariant(QObject::tr("Waiting for other side to accept"));
 			case FileTransfer::State::Negotiating:
-				return QVariant("Negotiating");
+				return QVariant(QObject::tr("Negotiating"));
 			case FileTransfer::State::Transferring:
-				return QVariant("Transferring");
+				return QVariant(QObject::tr("Transferring"));
 			case FileTransfer::State::Finished:
-				return QVariant("Finished");
+				return QVariant(QObject::tr("Finished"));
 			case FileTransfer::State::Failed:
-				return QVariant("Failed");
+				return QVariant(QObject::tr("Failed"));
 			case FileTransfer::State::Canceled:
-				return QVariant("Canceled");
+				return QVariant(QObject::tr("Canceled"));
 		}
 	}
 
-- 
cgit v0.10.2-6-g49f6