Skip to content

Commit

Permalink
Localization improvements and fixes (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fs00 authored Sep 8, 2023
1 parent 4d1864c commit c16e258
Show file tree
Hide file tree
Showing 34 changed files with 229 additions and 356 deletions.
16 changes: 0 additions & 16 deletions src/Cafe/Account/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ enum class OnlineAccountError
kPasswordCacheEmpty,
kNoPrincipalId,
};
template <>
struct fmt::formatter<OnlineAccountError> : formatter<string_view> {
template <typename FormatContext>
auto format(const OnlineAccountError v, FormatContext& ctx) {
switch (v)
{
case OnlineAccountError::kNoAccountId: return formatter<string_view>::format("AccountId missing (The account is not connected to a NNID)", ctx);
case OnlineAccountError::kNoPasswordCached: return formatter<string_view>::format("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)", ctx);
case OnlineAccountError::kPasswordCacheEmpty: return formatter<string_view>::format("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)", ctx);
case OnlineAccountError::kNoPrincipalId: return formatter<string_view>::format("PrincipalId missing", ctx);
default: break;
}
return formatter<string_view>::format("no error", ctx);
}
};


struct OnlineValidator
{
Expand Down
9 changes: 4 additions & 5 deletions src/Cafe/Filesystem/FST/KeyCache.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <wx/msgdlg.h>
#include <mutex>
#include <gui/helpers/wxHelpers.h>

#include "config/ActiveSettings.h"
#include "util/crypto/aes128.h"
Expand Down Expand Up @@ -74,7 +75,7 @@ void KeyCache_Prepare()
}
else
{
wxMessageBox("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to it's own directory, the disk is full or if anti-virus software is blocking Cemu.", "Error", wxOK | wxCENTRE | wxICON_ERROR);
wxMessageBox(_("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to its own directory, the disk is full or if anti-virus software is blocking Cemu."), _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
}
mtxKeyCache.unlock();
return;
Expand Down Expand Up @@ -107,10 +108,8 @@ void KeyCache_Prepare()
continue;
if( strishex(line) == false )
{
// show error message
char errorMsg[512];
sprintf(errorMsg, "Error in keys.txt in line %d\n", lineNumber);
wxMessageBox(errorMsg, "Error", wxOK | wxCENTRE | wxICON_ERROR);
auto errorMsg = formatWxString(_("Error in keys.txt at line {}"), lineNumber);
wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
continue;
}
if(line.size() == 32 )
Expand Down
13 changes: 8 additions & 5 deletions src/Cafe/GraphicPack/GraphicPack2Patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "boost/algorithm/string.hpp"

#include "gui/wxgui.h" // for wxMessageBox
#include "gui/helpers/wxHelpers.h"

// error handler
void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg)
Expand Down Expand Up @@ -39,29 +40,31 @@ void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumb

void PatchErrorHandler::showStageErrorMessageBox()
{
std::string errorMsg;
wxString errorMsg;
if (m_gp)
{
if (m_stage == STAGE::PARSER)
errorMsg.assign(fmt::format("Failed to load patches for graphic pack \'{}\'", m_gp->GetName()));
errorMsg.assign(formatWxString(_("Failed to load patches for graphic pack \'{}\'"), m_gp->GetName()));
else
errorMsg.assign(fmt::format("Failed to apply patches for graphic pack \'{}\'", m_gp->GetName()));
errorMsg.assign(formatWxString(_("Failed to apply patches for graphic pack \'{}\'"), m_gp->GetName()));
}
else
{
cemu_assert_debug(false); // graphic pack should always be set
}
if (cemuLog_isLoggingEnabled(LogType::Patches))
{
errorMsg.append("\n \nDetails:\n");
errorMsg.append("\n \n")
.append(_("Details:"))
.append("\n");
for (auto& itr : errorMessages)
{
errorMsg.append(itr);
errorMsg.append("\n");
}
}

wxMessageBox(errorMsg, "Graphic pack error");
wxMessageBox(errorMsg, _("Graphic pack error"));
}

// loads Cemu-style patches (patch_<anything>.asm)
Expand Down
5 changes: 2 additions & 3 deletions src/Cafe/HW/Latte/Core/LatteShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,9 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path
if (hasOldCacheFiles && !hasNewCacheFiles)
{
// ask user if they want to delete or keep the old cache file
const auto infoMsg = L"Outdated shader cache\n\nCemu detected that the shader cache for this game is outdated\nOnly shader caches generated with Cemu 1.25.0 or above are supported\n\n"
"We recommend deleting the outdated cache file as it will no longer be used by Cemu";
auto infoMsg = _("Cemu detected that the shader cache for this game is outdated.\nOnly shader caches generated with Cemu 1.25.0 or above are supported.\n\nWe recommend deleting the outdated cache file as it will no longer be used by Cemu.");

wxMessageDialog dialog(nullptr, _(infoMsg), _("Outdated shader cache"),
wxMessageDialog dialog(nullptr, infoMsg, _("Outdated shader cache"),
wxYES_NO | wxCENTRE | wxICON_EXCLAMATION);

dialog.SetYesNoLabels(_("Delete outdated cache file [recommended]"), _("Keep outdated cache file"));
Expand Down
16 changes: 8 additions & 8 deletions src/Cemu/Tools/DownloadManager/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ bool DownloadManager::syncAccountTickets()
for (auto& tiv : resultTicketIds.tivs)
{
index++;
std::string msg = _("Downloading account ticket").ToStdString();
std::string msg = _("Downloading account ticket").utf8_string();
msg.append(fmt::format(" {0}/{1}", index, count));
setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING);
// skip if already cached
Expand Down Expand Up @@ -508,7 +508,7 @@ bool DownloadManager::syncUpdateTickets()
if (titleIdParser.GetType() != TitleIdParser::TITLE_TYPE::BASE_TITLE_UPDATE)
continue;

std::string msg = _("Downloading ticket").ToStdString();
std::string msg = _("Downloading ticket").utf8_string();
msg.append(fmt::format(" {0}/{1}", updateIndex, numUpdates));
updateIndex++;
setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING);
Expand Down Expand Up @@ -561,7 +561,7 @@ bool DownloadManager::syncTicketCache()
for (auto& ticketInfo : m_ticketCache)
{
index++;
std::string msg = _("Downloading meta data").ToStdString();
std::string msg = _("Downloading meta data").utf8_string();
msg.append(fmt::format(" {0}/{1}", index, count));
setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING);
prepareIDBE(ticketInfo.titleId);
Expand Down Expand Up @@ -1054,7 +1054,7 @@ void DownloadManager::asyncPackageDownloadTMD(Package* package)
std::unique_lock<std::recursive_mutex> _l(m_mutex);
if (!tmdResult.isValid)
{
setPackageError(package, from_wxString(_("TMD download failed")));
setPackageError(package, _("TMD download failed").utf8_string());
package->state.isDownloadingTMD = false;
return;
}
Expand All @@ -1063,7 +1063,7 @@ void DownloadManager::asyncPackageDownloadTMD(Package* package)
NCrypto::TMDParser tmdParser;
if (!tmdParser.parse(tmdResult.tmdData.data(), tmdResult.tmdData.size()))
{
setPackageError(package, from_wxString(_("Invalid TMD")));
setPackageError(package, _("Invalid TMD").utf8_string());
package->state.isDownloadingTMD = false;
return;
}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i
size_t bytesWritten = callbackInfo->receiveBuffer.size();
if (callbackInfo->fileOutput->writeData(callbackInfo->receiveBuffer.data(), callbackInfo->receiveBuffer.size()) != (uint32)callbackInfo->receiveBuffer.size())
{
callbackInfo->downloadMgr->setPackageError(callbackInfo->package, from_wxString(_("Cannot write file. Disk full?")));
callbackInfo->downloadMgr->setPackageError(callbackInfo->package, _("Cannot write file. Disk full?").utf8_string());
return false;
}
callbackInfo->receiveBuffer.clear();
Expand All @@ -1193,12 +1193,12 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i
callbackInfoData.fileOutput = FileStream::createFile2(packageDownloadPath / fmt::format("{:08x}.app", contentId));
if (!callbackInfoData.fileOutput)
{
setPackageError(package, from_wxString(_("Cannot create file")));
setPackageError(package, _("Cannot create file").utf8_string());
return;
}
if (!NAPI::CCS_GetContentFile(titleId, contentId, CallbackInfo::writeCallback, &callbackInfoData))
{
setPackageError(package, from_wxString(_("Download failed")));
setPackageError(package, _("Download failed").utf8_string());
delete callbackInfoData.fileOutput;
return;
}
Expand Down
19 changes: 10 additions & 9 deletions src/config/CemuConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Cafe/Account/Account.h"

#include <wx/language.h>
#include <wx/intl.h>

struct GameEntry
{
Expand Down Expand Up @@ -258,15 +259,15 @@ struct fmt::formatter<CafeConsoleRegion> : formatter<string_view> {
string_view name;
switch (v)
{
case CafeConsoleRegion::JPN: name = "Japan"; break;
case CafeConsoleRegion::USA: name = "USA"; break;
case CafeConsoleRegion::EUR: name = "Europe"; break;
case CafeConsoleRegion::AUS_DEPR: name = "Australia"; break;
case CafeConsoleRegion::CHN: name = "China"; break;
case CafeConsoleRegion::KOR: name = "Korea"; break;
case CafeConsoleRegion::TWN: name = "Taiwan"; break;
case CafeConsoleRegion::Auto: name = "Auto"; break;
default: name = "many"; break;
case CafeConsoleRegion::JPN: name = wxTRANSLATE("Japan"); break;
case CafeConsoleRegion::USA: name = wxTRANSLATE("USA"); break;
case CafeConsoleRegion::EUR: name = wxTRANSLATE("Europe"); break;
case CafeConsoleRegion::AUS_DEPR: name = wxTRANSLATE("Australia"); break;
case CafeConsoleRegion::CHN: name = wxTRANSLATE("China"); break;
case CafeConsoleRegion::KOR: name = wxTRANSLATE("Korea"); break;
case CafeConsoleRegion::TWN: name = wxTRANSLATE("Taiwan"); break;
case CafeConsoleRegion::Auto: name = wxTRANSLATE("Auto"); break;
default: name = wxTRANSLATE("many"); break;

}
return formatter<string_view>::format(name, ctx);
Expand Down
45 changes: 11 additions & 34 deletions src/gui/CemuApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ void unused_translation_dummy()
void(_("Browse"));
void(_("Select a file"));
void(_("Select a directory"));

void(_("base"));
void(_("update"));
void(_("dlc"));
void(_("save"));

void(_("Japan"));
void(_("USA"));
void(_("Europe"));
void(_("Australia"));
void(_("China"));
void(_("Korea"));
void(_("Taiwan"));
void(_("Auto"));
void(_("many"));

void(_("Japanese"));
void(_("English"));
Expand All @@ -67,13 +52,6 @@ void unused_translation_dummy()
void(_("Russian"));
void(_("Taiwanese"));
void(_("unknown"));


// account.h
void(_("AccountId missing (The account is not connected to a NNID)"));
void(_("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)"));
void(_("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)"));
void(_("PrincipalId missing"));
}

bool CemuApp::OnInit()
Expand Down Expand Up @@ -110,7 +88,8 @@ bool CemuApp::OnInit()
#endif
auto failed_write_access = ActiveSettings::LoadOnce(exePath, user_data_path, config_path, cache_path, data_path);
for (auto&& path : failed_write_access)
wxMessageBox(fmt::format("Cemu can't write to {} !", path.generic_string()), _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr);
wxMessageBox(formatWxString(_("Cemu can't write to {}!"), path.generic_string()),
_("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr);

NetworkConfig::LoadOnce();
g_config.Load();
Expand Down Expand Up @@ -288,9 +267,10 @@ void CemuApp::CreateDefaultFiles(bool first_start)
// check for mlc01 folder missing if custom path has been set
if (!fs::exists(mlc) && !first_start)
{
const std::wstring message = fmt::format(fmt::runtime(_(L"Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?").ToStdWstring()), mlc.wstring());
const wxString message = formatWxString(_("Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?"),
_pathToUtf8(mlc));

wxMessageDialog dialog(nullptr, message, "Error", wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING);
wxMessageDialog dialog(nullptr, message, _("Error"), wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING);
dialog.SetYesNoCancelLabels(_("Yes"), _("No"), _("Select a custom path"));
const auto dialogResult = dialog.ShowModal();
if (dialogResult == wxID_NO)
Expand Down Expand Up @@ -362,16 +342,15 @@ void CemuApp::CreateDefaultFiles(bool first_start)
}
catch (const std::exception& ex)
{
std::stringstream errorMsg;
errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString()), ex.what(), _pathToUtf8(mlc));
wxString errorMsg = formatWxString(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}"), ex.what(), _pathToUtf8(mlc));

#if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError();
if (lastError != ERROR_SUCCESS)
errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError));

wxMessageBox(errorMsg.str(), "Error", wxOK | wxCENTRE | wxICON_ERROR);
#endif

wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
exit(0);
}

Expand All @@ -388,17 +367,15 @@ void CemuApp::CreateDefaultFiles(bool first_start)
}
catch (const std::exception& ex)
{
std::stringstream errorMsg;
errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString()), ex.what());
wxString errorMsg = formatWxString(_("Couldn't create a required cemu directory or file!\n\nError: {0}"), ex.what());

#if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError();
if (lastError != ERROR_SUCCESS)
errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError));


wxMessageBox(errorMsg.str(), "Error", wxOK | wxCENTRE | wxICON_ERROR);
#endif

wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
exit(0);
}
}
Expand Down
Loading

0 comments on commit c16e258

Please sign in to comment.