From 51e3e078be10a085702014b4b873d69c502e8b0a Mon Sep 17 00:00:00 2001 From: Silarn Date: Sat, 14 Dec 2019 18:11:57 -0600 Subject: Fix problem with translated unmanaged mods and origin names - (Also adds translatable strings to directoryentry.cpp) --- src/shared/directoryentry.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/shared/directoryentry.cpp') diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index 2cdbac74..00bf319e 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include namespace MOShared { @@ -83,7 +84,7 @@ public: return m_Origins[iter->second]; } else { std::ostringstream stream; - stream << "invalid origin name: " << ToString(name, false); + stream << QObject::tr("invalid origin name: ").toStdString() << ToString(name, true); throw std::runtime_error(stream.str()); } } @@ -106,7 +107,7 @@ public: m_OriginsNameMap.erase(iter); m_OriginsNameMap[newName] = idx; } else { - log::error("failed to change name lookup from {} to {}", oldName, newName); + log::error(QObject::tr("failed to change name lookup from {} to {}").toStdString(), oldName, newName); } } @@ -520,7 +521,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di WIN32_FILE_ATTRIBUTE_DATA fileData; if (::GetFileAttributesExW(fileName.c_str(), GetFileExInfoStandard, &fileData) == 0) { - throw windows_error("failed to determine file time"); + throw windows_error(QObject::tr("failed to determine file time").toStdString()); } FILETIME now; ::GetSystemTimeAsFileTime(&now); @@ -542,7 +543,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di BSA::EErrorCode res = archive.read(ToString(fileName, false).c_str(), false); if ((res != BSA::ERROR_NONE) && (res != BSA::ERROR_INVALIDHASHES)) { std::ostringstream stream; - stream << "invalid bsa file: " << ToString(fileName, false) << " errorcode " << res << " - " << ::GetLastError(); + stream << QObject::tr("invalid bsa file: ").toStdString() << ToString(fileName, false) << " errorcode " << res << " - " << ::GetLastError(); throw std::runtime_error(stream.str()); } @@ -718,12 +719,12 @@ void DirectoryEntry::removeFile(FileEntry::Index index) m_Files.erase(iter); } else { log::error( - "file \"{}\" not in directory \"{}\"", + QObject::tr("file \"{}\" not in directory \"{}\"").toStdString(), m_FileRegister->getFile(index)->getName(), this->getName()); } } else { log::error( - "file \"{}\" not in directory \"{}\", directory empty", + QObject::tr("file \"{}\" not in directory \"{}\", directory empty").toStdString(), m_FileRegister->getFile(index)->getName(), this->getName()); } } @@ -847,7 +848,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const DirectoryEntry *temp = findSubDirectory(pathComponent); if (temp != nullptr) { if (len >= path.size()) { - log::error("unexpected end of path"); + log::error(QObject::tr("unexpected end of path").toStdString()); return FileEntry::Ptr(); } return temp->searchFile(path.substr(len + 1), directory); @@ -991,7 +992,7 @@ bool FileRegister::removeFile(FileEntry::Index index) m_Files.erase(index); return true; } else { - log::error("invalid file index for remove: {}", index); + log::error(QObject::tr("invalid file index for remove: {}").toStdString(), index); return false; } } @@ -1005,7 +1006,7 @@ void FileRegister::removeOrigin(FileEntry::Index index, int originID) m_Files.erase(iter); } } else { - log::error("invalid file index for remove (for origin): {}", index); + log::error(QObject::tr("invalid file index for remove (for origin): {}").toStdString(), index); } } -- cgit v1.3.1