Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-16 12:04:50 +02:00
parent 42f7e46d08
commit b13c3ee582
4 changed files with 34 additions and 23 deletions

View file

@ -44,10 +44,12 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
mMenuColorPrimary, ALIGN_CENTER); mMenuColorPrimary, ALIGN_CENTER);
mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1}); mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1});
mGameCounter = std::make_shared<TextComponent>( const std::string gameProcessText {Utils::String::format(
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) + _n("%i OF %i GAME PROCESSED", "%i OF %i GAMES PROCESSED", mTotalGames), mGamesProcessed,
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED", mTotalGames)};
Font::get(FONT_SIZE_SMALL), mMenuColorSecondary, ALIGN_CENTER);
mGameCounter = std::make_shared<TextComponent>(gameProcessText, Font::get(FONT_SIZE_SMALL),
mMenuColorSecondary, ALIGN_CENTER);
mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1}); mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1});
// Spacer row with top border. // Spacer row with top border.
@ -321,15 +323,16 @@ void GuiOfflineGenerator::update(int deltaTime)
// Update the statistics. // Update the statistics.
mStatus->setText(_("RUNNING")); mStatus->setText(_("RUNNING"));
mGameCounter->setText(std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) + mGameCounter->setText(Utils::String::format(
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED"); _n("%i OF %i GAME PROCESSED", "%i OF %i GAMES PROCESSED", mTotalGames), mGamesProcessed,
mTotalGames));
mGeneratedVal->setText(std::to_string(mImagesGenerated)); mGeneratedVal->setText(std::to_string(mImagesGenerated));
mFailedVal->setText(std::to_string(mGamesFailed)); mFailedVal->setText(std::to_string(mGamesFailed));
mOverwrittenVal->setText(std::to_string(mImagesOverwritten)); mOverwrittenVal->setText(std::to_string(mImagesOverwritten));
if (mGamesProcessed == mTotalGames) { if (mGamesProcessed == mTotalGames) {
mStatus->setText(_("COMPLETED")); mStatus->setText(_("COMPLETED [MIXIMAGE GENERATOR]"));
mStartPauseButton->setText(_("DONE"), _("done (close)")); mStartPauseButton->setText(_("DONE"), _("done (close)"));
mStartPauseButton->setPressedFunc([this]() { delete this; }); mStartPauseButton->setPressedFunc([this]() { delete this; });
mCloseButton->setText(_("CLOSE"), _("close")); mCloseButton->setText(_("CLOSE"), _("close"));

View file

@ -329,7 +329,8 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
<< "\""; << "\"";
{ {
std::unique_lock<std::mutex> lock {mMutex}; std::unique_lock<std::mutex> lock {mMutex};
mErrorMessage = "A flatten.txt file was found, skipping \"" + currentSystem + "\""; mErrorMessage = Utils::String::format(
_("A flatten.txt file was found, skipping \"%s\""), currentSystem.c_str());
} }
continue; continue;
} }
@ -522,7 +523,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
<< "\""; << "\"";
{ {
std::unique_lock<std::mutex> lock {mMutex}; std::unique_lock<std::mutex> lock {mMutex};
mErrorMessage = "A flatten.txt file was found, skipping \"" + currentSystem + "\""; mErrorMessage = Utils::String::format(
_("A flatten.txt file was found, skipping \"%s\""), currentSystem.c_str());
} }
continue; continue;
} }
@ -549,8 +551,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
LOG(LogError) << "Couldn't parse file \"" << gamelistFile << "\""; LOG(LogError) << "Couldn't parse file \"" << gamelistFile << "\"";
{ {
std::unique_lock<std::mutex> lock {mMutex}; std::unique_lock<std::mutex> lock {mMutex};
mErrorMessage = mErrorMessage = Utils::String::format(
"Couldn't parse gamelist.xml file for \"" + system->getName() + "\""; _("Couldn't parse gamelist.xml file for \"%s\""), system->getName().c_str());
} }
SDL_Delay(500); SDL_Delay(500);
continue; continue;
@ -575,7 +577,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
{ {
std::unique_lock<std::mutex> lock {mMutex}; std::unique_lock<std::mutex> lock {mMutex};
mErrorMessage = mErrorMessage =
"Couldn't find a gamelist tag in file for system \"" + system->getName() + "\""; Utils::String::format(_("Couldn't find a gamelist tag in file for \"%s\""),
system->getName().c_str());
} }
SDL_Delay(500); SDL_Delay(500);
continue; continue;

View file

@ -223,11 +223,10 @@ void GuiScraperMulti::doNextSearch()
std::stringstream ss; std::stringstream ss;
if (mQueueCountPerSystem.size() > 1) { if (mQueueCountPerSystem.size() > 1) {
// const int gameCount {++mQueueCountPerSystem[mSearchQueue.front().system].first};
const int totalGameCount {mQueueCountPerSystem[mSearchQueue.front().system].second}; const int totalGameCount {mQueueCountPerSystem[mSearchQueue.front().system].second};
const std::string gameCountText {_n("GAME", "GAMES", totalGameCount)};
mSystem->setText(Utils::String::toUpper(mSearchQueue.front().system->getFullName()) + " [" + mSystem->setText(Utils::String::toUpper(mSearchQueue.front().system->getFullName()) + " [" +
std::to_string(totalGameCount) + " GAME" + std::to_string(totalGameCount) + " " + gameCountText + "]");
(totalGameCount == 1 ? "]" : "S]"));
} }
else { else {
mSystem->setText(Utils::String::toUpper(mSearchQueue.front().system->getFullName())); mSystem->setText(Utils::String::toUpper(mSearchQueue.front().system->getFullName()));
@ -269,8 +268,9 @@ void GuiScraperMulti::doNextSearch()
// Update subtitle. // Update subtitle.
ss.str(""); ss.str("");
ss << "GAME " << (mCurrentGame + 1) << " OF " << mTotalGames << " - " << folderPath const std::string gameCounterText {
<< scrapeName Utils::String::format(_("GAME %i OF %i"), mCurrentGame + 1, mTotalGames)};
ss << gameCounterText << " - " << folderPath << scrapeName
<< ((mSearchQueue.front().game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : << ((mSearchQueue.front().game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR :
""); "");
mSubtitle->setText(ss.str()); mSubtitle->setText(ss.str());
@ -313,12 +313,14 @@ void GuiScraperMulti::finish()
ss << _("NO GAMES WERE SCRAPED"); ss << _("NO GAMES WERE SCRAPED");
} }
else { else {
ss << mTotalSuccessful << " GAME" << ((mTotalSuccessful > 1) ? "S" : "") ss << Utils::String::format(
<< " SUCCESSFULLY SCRAPED"; _n("%i GAME SUCCESSFULLY SCRAPED", "%i GAMES SUCCESSFULLY SCRAPED", mTotalSuccessful),
mTotalSuccessful);
if (mTotalSkipped > 0) if (mTotalSkipped > 0)
ss << "\n" ss << "\n"
<< mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED"; << Utils::String::format(_n("%i GAME SKIPPED", "%i GAMES SKIPPED", mTotalSkipped),
mTotalSkipped);
} }
// Pressing either OK or using the back button should delete us. // Pressing either OK or using the back button should delete us.

View file

@ -45,10 +45,13 @@ GuiDetectDevice::GuiDetectDevice(bool firstRun,
std::stringstream deviceInfo; std::stringstream deviceInfo;
int numDevices {InputManager::getInstance().getNumJoysticks()}; int numDevices {InputManager::getInstance().getNumJoysticks()};
if (numDevices > 0) if (numDevices > 0) {
deviceInfo << numDevices << " GAMEPAD" << (numDevices > 1 ? "S" : "") << " DETECTED"; deviceInfo << Utils::String::format(
else _n("%i GAMEPAD DETECTED", "%i GAMEPADS DETECTED", numDevices), numDevices);
}
else {
deviceInfo << _("NO GAMEPADS DETECTED"); deviceInfo << _("NO GAMEPADS DETECTED");
}
if (numDevices > 1 && Settings::getInstance()->getBool("InputOnlyFirstController")) if (numDevices > 1 && Settings::getInstance()->getBool("InputOnlyFirstController"))
deviceInfo << " " << _("(ONLY ACCEPTING INPUT FROM FIRST CONTROLLER)"); deviceInfo << " " << _("(ONLY ACCEPTING INPUT FROM FIRST CONTROLLER)");