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

View file

@ -329,7 +329,8 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
<< "\"";
{
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;
}
@ -522,7 +523,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
<< "\"";
{
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;
}
@ -549,8 +551,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
LOG(LogError) << "Couldn't parse file \"" << gamelistFile << "\"";
{
std::unique_lock<std::mutex> lock {mMutex};
mErrorMessage =
"Couldn't parse gamelist.xml file for \"" + system->getName() + "\"";
mErrorMessage = Utils::String::format(
_("Couldn't parse gamelist.xml file for \"%s\""), system->getName().c_str());
}
SDL_Delay(500);
continue;
@ -575,7 +577,8 @@ void GuiOrphanedDataCleanup::cleanupGamelists()
{
std::unique_lock<std::mutex> lock {mMutex};
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);
continue;

View file

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

View file

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