Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-18 15:07:41 +02:00
parent 9207004bd2
commit 72ee58e748
10 changed files with 138 additions and 103 deletions

View file

@ -884,48 +884,51 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
};
switch (gameCount) {
case 1: {
desc = "This collection contains 1 game: '";
desc.append(gamesList[0]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[0]->getSourceFileData()->getSystem()->getName()))
.append("]'");
desc = Utils::String::format(
_("This collection contains 1 game: '%s [%s]'"),
gamesList[0]->metadata.get("name").c_str(),
caseConversion(gamesList[0]->getSourceFileData()->getSystem()->getName())
.c_str());
break;
}
case 2: {
desc = "This collection contains 2 games: '";
desc.append(gamesList[0]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[0]->getSourceFileData()->getSystem()->getName()))
.append("]' and '")
.append(gamesList[1]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[1]->getSourceFileData()->getSystem()->getName()))
.append("]'");
desc = Utils::String::format(
_("This collection contains 2 games: '%s [%s]' and '%s [%s]'"),
gamesList[0]->metadata.get("name").c_str(),
caseConversion(gamesList[0]->getSourceFileData()->getSystem()->getName())
.c_str(),
gamesList[1]->metadata.get("name").c_str(),
caseConversion(gamesList[1]->getSourceFileData()->getSystem()->getName())
.c_str());
break;
}
case 3: {
desc = Utils::String::format(
_("This collection contains 3 games: '%s [%s]', '%s [%s]' and '%s [%s]'"),
gamesList[0]->metadata.get("name").c_str(),
caseConversion(gamesList[0]->getSourceFileData()->getSystem()->getName())
.c_str(),
gamesList[1]->metadata.get("name").c_str(),
caseConversion(gamesList[1]->getSourceFileData()->getSystem()->getName())
.c_str(),
gamesList[2]->metadata.get("name").c_str(),
caseConversion(gamesList[2]->getSourceFileData()->getSystem()->getName())
.c_str());
break;
}
default: {
desc = "This collection contains ";
desc.append(std::to_string(gameCount))
.append(" games: '")
.append(gamesList[0]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[0]->getSourceFileData()->getSystem()->getName()))
.append("]', '")
.append(gamesList[1]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[1]->getSourceFileData()->getSystem()->getName()))
.append("]' and '")
.append(gamesList[2]->metadata.get("name"))
.append(" [")
.append(caseConversion(
gamesList[2]->getSourceFileData()->getSystem()->getName()))
.append("]'");
desc.append(gameCount == 3 ? "" : ", among others");
desc = Utils::String::format(
_("This collection contains %i games: '%s [%s]', '%s [%s]' and '%s [%s]', "
"among others"),
gameCount, gamesList[0]->metadata.get("name").c_str(),
caseConversion(gamesList[0]->getSourceFileData()->getSystem()->getName())
.c_str(),
gamesList[1]->metadata.get("name").c_str(),
caseConversion(gamesList[1]->getSourceFileData()->getSystem()->getName())
.c_str(),
gamesList[2]->metadata.get("name").c_str(),
caseConversion(gamesList[2]->getSourceFileData()->getSystem()->getName())
.c_str());
break;
}
}
@ -933,29 +936,31 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
else {
switch (gameCount) {
case 1: {
desc = "This collection contains 1 game: '";
desc.append(gamesList[0]->metadata.get("name")).append("'");
desc = Utils::String::format(_("This collection contains 1 game: '%s'"),
gamesList[0]->metadata.get("name").c_str());
break;
}
case 2: {
desc = "This collection contains 2 games: '";
desc.append(gamesList[0]->metadata.get("name"))
.append("' and '")
.append(gamesList[1]->metadata.get("name"))
.append("'");
desc =
Utils::String::format(_("This collection contains 2 games: '%s' and '%s'"),
gamesList[0]->metadata.get("name").c_str(),
gamesList[1]->metadata.get("name").c_str());
break;
}
case 3: {
desc = Utils::String::format(
_("This collection contains 3 games: '%s', '%s' and '%s'"),
gamesList[0]->metadata.get("name").c_str(),
gamesList[1]->metadata.get("name").c_str(),
gamesList[2]->metadata.get("name").c_str());
break;
}
default: {
desc = "This collection contains ";
desc.append(std::to_string(gameCount))
.append(" games: '")
.append(gamesList[0]->metadata.get("name"))
.append("', '")
.append(gamesList[1]->metadata.get("name"))
.append("' and '")
.append(gamesList[2]->metadata.get("name"))
.append("'");
desc.append(gameCount == 3 ? "" : ", among others");
desc = Utils::String::format(
_("This collection contains %i games: '%s', '%s' and '%s', among others"),
gameCount, gamesList[0]->metadata.get("name").c_str(),
gamesList[1]->metadata.get("name").c_str(),
gamesList[2]->metadata.get("name").c_str());
break;
}
}

View file

@ -1047,9 +1047,11 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: MISSING PRE-COMMAND FIND RULES CONFIGURATION FOR '" +
preCommand.first + "'",
6000);
window->queueInfoPopup(
Utils::String::format(
_("ERROR: MISSING PRE-COMMAND FIND RULES CONFIGURATION FOR '%s'"),
preCommand.first.c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1071,11 +1073,13 @@ void FileData::launchGame()
if (emulatorName == "")
window->queueInfoPopup(
"ERROR: COULDN'T FIND PRE-COMMAND, HAS IT BEEN PROPERLY INSTALLED?", 6000);
_("ERROR: COULDN'T FIND PRE-COMMAND, HAS IT BEEN PROPERLY INSTALLED?"), 6000);
else
window->queueInfoPopup("ERROR: COULDN'T FIND PRE-COMMAND '" + emulatorName +
"', HAS IT BEEN PROPERLY INSTALLED?",
6000);
window->queueInfoPopup(
Utils::String::format(
_("ERROR: COULDN'T FIND PRE-COMMAND '%s', HAS IT BEEN PROPERLY INSTALLED?"),
emulatorName.c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
@ -1170,7 +1174,9 @@ void FileData::launchGame()
LOG(LogError) << commandRaw;
window->queueInfoPopup(
"ERROR: MISSING EMULATOR FIND RULES CONFIGURATION FOR '" + emulator.first + "'", 6000);
Utils::String::format(_("ERROR: MISSING EMULATOR FIND RULES CONFIGURATION FOR '%s'"),
emulator.first.c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1205,24 +1211,28 @@ void FileData::launchGame()
#endif
if (isAndroidApp) {
if (emulatorName == "" || emulatorName == "%FILEINJECT%") {
window->queueInfoPopup("ERROR: COULDN'T FIND APP, HAS IT BEEN PROPERLY INSTALLED?",
6000);
window->queueInfoPopup(
_("ERROR: COULDN'T FIND APP, HAS IT BEEN PROPERLY INSTALLED?"), 6000);
}
else {
window->queueInfoPopup("ERROR: COULDN'T FIND APP '" + emulatorName +
"', HAS IT BEEN PROPERLY INSTALLED?",
6000);
window->queueInfoPopup(
Utils::String::format(
_("ERROR: COULDN'T FIND APP '%s', HAS IT BEEN PROPERLY INSTALLED?"),
emulatorName.c_str()),
6000);
}
}
else {
if (emulatorName == "") {
window->queueInfoPopup(
"ERROR: COULDN'T FIND EMULATOR, HAS IT BEEN PROPERLY INSTALLED?", 6000);
_("ERROR: COULDN'T FIND EMULATOR, HAS IT BEEN PROPERLY INSTALLED?"), 6000);
}
else {
window->queueInfoPopup("ERROR: COULDN'T FIND EMULATOR '" + emulatorName +
"', HAS IT BEEN PROPERLY INSTALLED?",
6000);
window->queueInfoPopup(
Utils::String::format(
_("ERROR: COULDN'T FIND EMULATOR '%s', HAS IT BEEN PROPERLY INSTALLED?"),
emulatorName.c_str()),
6000);
}
}
@ -1295,8 +1305,9 @@ void FileData::launchGame()
LOG(LogError) << commandRaw;
window->queueInfoPopup(
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)) + "'",
Utils::String::format(
_("ERROR: COULDN'T FIND EMULATOR CORE FILE '%s'"),
Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)).c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
@ -1317,7 +1328,7 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
window->queueInfoPopup(_("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1331,7 +1342,10 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: MISSING CORE CONFIGURATION FOR '" + coreEntry + "'", 6000);
window->queueInfoPopup(
Utils::String::format(_("ERROR: MISSING CORE CONFIGURATION FOR '%s'"),
coreEntry.c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1400,7 +1414,7 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
window->queueInfoPopup(_("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1416,8 +1430,9 @@ void FileData::launchGame()
LOG(LogError) << Utils::String::vectorToDelimitedString(emulatorCorePaths, ", ");
window->queueInfoPopup(
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
Utils::String::toUpper(coreName.substr(0, coreName.size()) + "'"),
Utils::String::format(
_("ERROR: COULDN'T FIND EMULATOR CORE FILE '%s'"),
Utils::String::toUpper(coreName.substr(0, coreName.size())).c_str()),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
@ -1464,7 +1479,8 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID %STARTDIR% VARIABLE ENTRY", 6000);
window->queueInfoPopup(
Utils::String::format(_("ERROR: INVALID %s VARIABLE ENTRY"), "%STARTDIR%"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1505,9 +1521,11 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: DIRECTORY DEFINED BY %STARTDIR% COULD NOT BE "
"CREATED, PERMISSION PROBLEMS?",
6000);
window->queueInfoPopup(
Utils::String::format(_("ERROR: DIRECTORY DEFINED BY %s COULD NOT BE "
"CREATED, PERMISSION PROBLEMS?"),
"%STARTDIR%"),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1563,7 +1581,8 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID %INJECT% VARIABLE ENTRY", 6000);
window->queueInfoPopup(
Utils::String::format(_("ERROR: INVALID %s VARIABLE ENTRY"), "%INJECT%"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1675,7 +1694,8 @@ void FileData::launchGame()
else {
LOG(LogError) << "App or alias file \"" << romPath
<< "\" doesn't exist or is unreadable";
window->queueInfoPopup("ERROR: APP OR ALIAS FILE DOESN'T EXIST OR IS UNREADABLE", 6000);
window->queueInfoPopup(_("ERROR: APP OR ALIAS FILE DOESN'T EXIST OR IS UNREADABLE"),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1729,7 +1749,7 @@ void FileData::launchGame()
desktopFileStream.close();
if (!validFile || !execEntry) {
LOG(LogError) << "File is invalid or unreadable";
window->queueInfoPopup("ERROR: DESKTOP FILE IS INVALID OR UNREADABLE", 6000);
window->queueInfoPopup(_("ERROR: DESKTOP FILE IS INVALID OR UNREADABLE"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1737,7 +1757,7 @@ void FileData::launchGame()
}
else {
LOG(LogError) << "Desktop file \"" << romPath << "\" doesn't exist or is unreadable";
window->queueInfoPopup("ERROR: DESKTOP FILE DOESN'T EXIST OR IS UNREADABLE", 6000);
window->queueInfoPopup(_("ERROR: DESKTOP FILE DOESN'T EXIST OR IS UNREADABLE"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1795,7 +1815,8 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
window->queueInfoPopup(_("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE"),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -1859,8 +1880,8 @@ void FileData::launchGame()
LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw;
window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE",
6000);
window->queueInfoPopup(
_("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE"), 6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
return;
@ -2025,10 +2046,11 @@ returnValue = Utils::Platform::launchGameUnix(command, startDirectory, runInBack
if (returnValue != 0) {
LOG(LogWarning) << "Launch terminated with nonzero return value " << returnValue;
window->queueInfoPopup("ERROR LAUNCHING GAME '" +
Utils::String::toUpper(metadata.get("name")) + "' (ERROR CODE " +
Utils::String::toUpper(std::to_string(returnValue) + ")"),
6000);
window->queueInfoPopup(
Utils::String::format(_("ERROR LAUNCHING GAME '%s' (ERROR CODE %i)"),
Utils::String::toUpper(metadata.get("name")).c_str(),
returnValue),
6000);
window->setAllowTextScrolling(true);
window->setAllowFileAnimation(true);
}

View file

@ -259,8 +259,8 @@ GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
});
}
else {
mMenu.addButton(_("APPLY"), _("APPLY"), [&] { delete this; });
mMenu.addButton(_("CANCEL"), _("CANCEL"), [&] {
mMenu.addButton(_("APPLY"), _("apply"), [&] { delete this; });
mMenu.addButton(_("CANCEL"), _("cancel"), [&] {
mCancelled = true;
delete this;
});

View file

@ -541,7 +541,12 @@ void GuiMenu::openUIOptions()
it != SystemData::sSystemVector.cend(); ++it) {
// If required, abbreviate the system name so it doesn't overlap the setting name.
float maxNameLength {mSize.x * 0.51f};
startupSystem->add(Utils::String::toUpper((*it)->getFullName()), (*it)->getName(),
std::string sysName {(*it)->getFullName()};
if ((*it)->isCollection() && (sysName == "collections" || sysName == "all games" ||
sysName == "favorites" || sysName == "last played")) {
sysName = _(sysName.c_str());
}
startupSystem->add(Utils::String::toUpper(sysName), (*it)->getName(),
Settings::getInstance()->getString("StartupSystem") == (*it)->getName(),
maxNameLength);
}

View file

@ -558,7 +558,7 @@ void GuiScraperSearch::onSearchError(const std::string& error,
{
if (fatalError) {
LOG(LogWarning) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "OK",
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), _("OK"),
mCancelCallback, "", nullptr, "", nullptr, nullptr, true));
return;
}

View file

@ -39,7 +39,7 @@ GuiSettings::GuiSettings(std::string title)
, mInvalidateCachedBackground {false}
{
addChild(&mMenu);
mMenu.addButton(_("BACK"), "back", [this] { delete this; });
mMenu.addButton(_("BACK"), _("back"), [this] { delete this; });
setSize(Renderer::getScreenWidth(), Renderer::getScreenHeight());
mMenu.setPosition((mSize.x - mMenu.getSize().x) / 2.0f, Renderer::getScreenHeight() * 0.13f);

View file

@ -130,7 +130,7 @@ GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback)
std::vector<std::shared_ptr<ButtonComponent>> buttons;
buttons.push_back(
std::make_shared<ButtonComponent>(_("CLOSE"), _("CLOSE"), [&] { delete this; }));
std::make_shared<ButtonComponent>(_("CLOSE"), _("close"), [&] { delete this; }));
mButtons = MenuComponent::makeButtonGrid(buttons);
mGrid.setEntry(mButtons, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1},
GridFlags::BORDER_TOP);

View file

@ -158,8 +158,8 @@ void ViewController::legacyAppDataDialog()
#endif
mWindow->pushGui(new GuiMsgBox(
HelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", nullptr, nullptr, true,
true,
HelpStyle(), upgradeMessage.c_str(), _("OK"), [] {}, "", nullptr, "", nullptr, nullptr,
true, true,
(mRenderer->getIsVerticalOrientation() ?
0.85f :
0.55f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -981,7 +981,9 @@ void ViewController::launch(FileData* game)
// If the game launch screen has been set as disabled, show a simple info popup
// notification instead.
mWindow->queueInfoPopup(
"LAUNCHING GAME '" + Utils::String::toUpper(game->metadata.get("name") + "'"), 10000);
Utils::String::format(_("LAUNCHING GAME '%s'"),
Utils::String::toUpper(game->metadata.get("name")).c_str()),
10000);
duration = 1700;
}
else if (durationString == "brief") {

View file

@ -53,7 +53,7 @@ public:
case ASYNC_DONE:
return "done";
default:
return "something impossible has occured; row, row, fight the power";
return "something impossible has occured";
}
}

View file

@ -10,6 +10,7 @@
#include "Window.h"
#include "resources/Font.h"
#include "utils/LocalizationUtil.h"
#define MOVE_REPEAT_DELAY 500
#define MOVE_REPEAT_RATE 40
@ -212,6 +213,6 @@ void SliderComponent::onValueChanged()
std::vector<HelpPrompt> SliderComponent::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
prompts.push_back(HelpPrompt("left/right", "change value"));
prompts.push_back(HelpPrompt("left/right", _("change value")));
return prompts;
}