Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-17 19:51:18 +02:00
parent 13fadd1658
commit 47a8363f32
5 changed files with 86 additions and 33 deletions

View file

@ -397,10 +397,12 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
parentRootFolder->getSortTypeString()), parentRootFolder->getSortTypeString()),
favoritesSorting); favoritesSorting);
mWindow->queueInfoPopup( mWindow->queueInfoPopup(
"DISABLED '" + Utils::String::format(
_("DISABLED '%s' IN '%s'"),
Utils::String::toUpper( Utils::String::toUpper(
Utils::String::removeParenthesis(file->getName())) + Utils::String::removeParenthesis(file->getName()))
"' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'", .c_str(),
Utils::String::toUpper(sysData.system->getName()).c_str()),
4000); 4000);
} }
else { else {
@ -786,14 +788,19 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
ViewController::getInstance()->reloadGamelistView( ViewController::getInstance()->reloadGamelistView(
mAutoCollectionSystemsData["favorites"].system); mAutoCollectionSystemsData["favorites"].system);
} }
std::string sysTemp {sysName};
if (sysTemp == "Favorites")
sysTemp = _("Favorites");
if (adding) { if (adding) {
mWindow->queueInfoPopup("ADDED '" + Utils::String::toUpper(name) + "' TO '" + mWindow->queueInfoPopup(Utils::String::format(_("ADDED '%s' TO '%s'"),
Utils::String::toUpper(sysName) + "'", Utils::String::toUpper(name).c_str(),
Utils::String::toUpper(sysTemp).c_str()),
4000); 4000);
} }
else { else {
mWindow->queueInfoPopup("REMOVED '" + Utils::String::toUpper(name) + "' FROM '" + mWindow->queueInfoPopup(Utils::String::format(_("REMOVED '%s' FROM '%s'"),
Utils::String::toUpper(sysName) + "'", Utils::String::toUpper(name).c_str(),
Utils::String::toUpper(sysTemp).c_str()),
4000); 4000);
} }
return true; return true;
@ -825,7 +832,7 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
FileData* rootFolder {sys->getRootFolder()}; FileData* rootFolder {sys->getRootFolder()};
FileFilterIndex* idx {rootFolder->getSystem()->getIndex()}; FileFilterIndex* idx {rootFolder->getSystem()->getIndex()};
std::string desc {"This collection is empty"}; std::string desc {_("This collection is empty")};
std::vector<FileData*> gamesList; std::vector<FileData*> gamesList;
std::vector<FileData*> gamesListRandom; std::vector<FileData*> gamesListRandom;

View file

@ -593,7 +593,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
else if (newVal == "" && else if (newVal == "" &&
(currentKey == "developer" || currentKey == "publisher" || (currentKey == "developer" || currentKey == "publisher" ||
currentKey == "genre" || currentKey == "players")) { currentKey == "genre" || currentKey == "players")) {
ed->setValue("unknown"); ed->setValue(_("unknown"));
if (originalValue == "unknown") if (originalValue == "unknown")
ed->setColor(mMenuColorPrimary); ed->setColor(mMenuColorPrimary);
else else
@ -601,11 +601,18 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
} }
else { else {
ed->setValue(newVal); ed->setValue(newVal);
if ((currentKey == "developer" || currentKey == "publisher" ||
currentKey == "genre" || currentKey == "players") &&
newVal == _("unknown") && newVal == _(originalValue.c_str())) {
ed->setColor(mMenuColorPrimary);
}
else {
if (newVal == originalValue) if (newVal == originalValue)
ed->setColor(mMenuColorPrimary); ed->setColor(mMenuColorPrimary);
else else
ed->setColor(mMenuColorBlue); ed->setColor(mMenuColorBlue);
} }
}
}; };
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
@ -645,6 +652,11 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
ed->setValue(ViewController::EXCLAMATION_CHAR + " " + mMetaData->get(it->key)); ed->setValue(ViewController::EXCLAMATION_CHAR + " " + mMetaData->get(it->key));
} }
else { else {
if ((currentKey == "developer" || currentKey == "publisher" || currentKey == "genre" ||
currentKey == "players") &&
mMetaData->get(it->key) == "unknown")
ed->setValue(_(mMetaData->get(it->key).c_str()));
else
ed->setValue(mMetaData->get(it->key)); ed->setValue(mMetaData->get(it->key));
} }
@ -784,7 +796,7 @@ void GuiMetaDataEd::save()
bool setGameAsCounted {false}; bool setGameAsCounted {false};
int offset {0}; int offset {0};
for (unsigned int i = 0; i < mEditors.size(); ++i) { for (unsigned int i {0}; i < mEditors.size(); ++i) {
// The offset is needed to make the editor and metadata fields match up if we're // The offset is needed to make the editor and metadata fields match up if we're
// skipping the custom collections sortname field (which we do if not editing the // skipping the custom collections sortname field (which we do if not editing the
// game from within a custom collection gamelist). // game from within a custom collection gamelist).
@ -803,7 +815,7 @@ void GuiMetaDataEd::save()
continue; continue;
if (key == "controller" && mEditors.at(i)->getValue() != "") { if (key == "controller" && mEditors.at(i)->getValue() != "") {
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue()); std::string shortName {BadgeComponent::getShortName(mEditors.at(i)->getValue())};
if (shortName != "unknown") if (shortName != "unknown")
mMetaData->set(key, shortName); mMetaData->set(key, shortName);
continue; continue;
@ -819,8 +831,14 @@ void GuiMetaDataEd::save()
setGameAsCounted = true; setGameAsCounted = true;
} }
if ((key == "developer" || key == "publisher" || key == "genre" || key == "players") &&
mEditors.at(i)->getValue() == _("unknown")) {
mMetaData->set(key, "unknown");
}
else {
mMetaData->set(key, mEditors.at(i)->getValue()); mMetaData->set(key, mEditors.at(i)->getValue());
} }
}
// If hidden games are not shown and the hide flag was set for the entry, then write the // If hidden games are not shown and the hide flag was set for the entry, then write the
// metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file // metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file
@ -980,6 +998,11 @@ void GuiMetaDataEd::close()
std::string mMetaDataValue {mMetaData->get(key)}; std::string mMetaDataValue {mMetaData->get(key)};
std::string mEditorsValue {mEditors.at(i)->getValue()}; std::string mEditorsValue {mEditors.at(i)->getValue()};
if ((key == "developer" || key == "publisher" || key == "genre" || key == "players") &&
mEditorsValue == _("unknown")) {
mEditorsValue = "unknown";
}
if (key == "controller" && mEditors.at(i)->getValue() != "") { if (key == "controller" && mEditors.at(i)->getValue() != "") {
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue()); std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
if (shortName == "unknown" || mMetaDataValue == shortName) if (shortName == "unknown" || mMetaDataValue == shortName)

View file

@ -648,10 +648,27 @@ void GuiScraperSearch::updateInfoPane()
mMD_Rating->setOpacity(1.0f); mMD_Rating->setOpacity(1.0f);
} }
mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate"))); mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate")));
if (res.mdl.get("developer") == "unknown")
mMD_Developer->setText(Utils::String::toUpper(_(res.mdl.get("developer").c_str())));
else
mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer"))); mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer")));
if (res.mdl.get("publisher") == "unknown")
mMD_Publisher->setText(Utils::String::toUpper(_(res.mdl.get("publisher").c_str())));
else
mMD_Publisher->setText(Utils::String::toUpper(res.mdl.get("publisher"))); mMD_Publisher->setText(Utils::String::toUpper(res.mdl.get("publisher")));
if (res.mdl.get("genre") == "unknown")
mMD_Genre->setText(Utils::String::toUpper(_(res.mdl.get("genre").c_str())));
else
mMD_Genre->setText(Utils::String::toUpper(res.mdl.get("genre"))); mMD_Genre->setText(Utils::String::toUpper(res.mdl.get("genre")));
if (res.mdl.get("players") == "unknown")
mMD_Players->setText(Utils::String::toUpper(_(res.mdl.get("players").c_str())));
else
mMD_Players->setText(Utils::String::toUpper(res.mdl.get("players"))); mMD_Players->setText(Utils::String::toUpper(res.mdl.get("players")));
mGrid.onSizeChanged(); mGrid.onSizeChanged();
} }
else { else {

View file

@ -17,6 +17,7 @@
#include "FileFilterIndex.h" #include "FileFilterIndex.h"
#include "UIModeController.h" #include "UIModeController.h"
#include "guis/GuiGamelistOptions.h" #include "guis/GuiGamelistOptions.h"
#include "utils/LocalizationUtil.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GamelistBase::GamelistBase(FileData* root) GamelistBase::GamelistBase(FileData* root)
@ -270,13 +271,14 @@ bool GamelistBase::input(InputConfig* config, Input input)
mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() == "collections") { getCursor()->getParent()->getPath() == "collections") {
NavigationSounds::getInstance().playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance().playThemeNavigationSound(FAVORITESOUND);
mWindow->queueInfoPopup("CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS", 4000); mWindow->queueInfoPopup(_("CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS"),
4000);
} }
// Notify the user if attempting to add a placeholder to a custom collection. // Notify the user if attempting to add a placeholder to a custom collection.
if (CollectionSystemsManager::getInstance()->isEditing() && if (CollectionSystemsManager::getInstance()->isEditing() &&
mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) { mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) {
NavigationSounds::getInstance().playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance().playThemeNavigationSound(FAVORITESOUND);
mWindow->queueInfoPopup("CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS", 4000); mWindow->queueInfoPopup(_("CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS"), 4000);
} }
else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() != "collections") { getCursor()->getParent()->getPath() != "collections") {
@ -385,26 +387,28 @@ bool GamelistBase::input(InputConfig* config, Input input)
// CollectionSystemsManager. // CollectionSystemsManager.
if (entryToUpdate->getType() == FOLDER) { if (entryToUpdate->getType() == FOLDER) {
if (isEditing) { if (isEditing) {
mWindow->queueInfoPopup("CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", 4000); mWindow->queueInfoPopup(_("CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS"), 4000);
} }
else { else {
MetaDataList* md {&entryToUpdate->getSourceFileData()->metadata}; MetaDataList* md {&entryToUpdate->getSourceFileData()->metadata};
if (md->get("favorite") == "false") { if (md->get("favorite") == "false") {
md->set("favorite", "true"); md->set("favorite", "true");
mWindow->queueInfoPopup( mWindow->queueInfoPopup(
"MARKED FOLDER '" + Utils::String::format(
Utils::String::toUpper(Utils::String::removeParenthesis( _("MARKED FOLDER '%s' AS FAVORITE"),
entryToUpdate->getName())) + Utils::String::toUpper(
"' AS FAVORITE", Utils::String::removeParenthesis(entryToUpdate->getName()))
.c_str()),
4000); 4000);
} }
else { else {
md->set("favorite", "false"); md->set("favorite", "false");
mWindow->queueInfoPopup( mWindow->queueInfoPopup(
"REMOVED FAVORITE MARKING FOR FOLDER '" + Utils::String::format(
Utils::String::toUpper(Utils::String::removeParenthesis( _("REMOVED FAVORITE MARKING FOR FOLDER '%s'"),
entryToUpdate->getName())) + Utils::String::toUpper(
"'", Utils::String::removeParenthesis(entryToUpdate->getName()))
.c_str()),
4000); 4000);
} }
} }
@ -430,8 +434,8 @@ bool GamelistBase::input(InputConfig* config, Input input)
return true; return true;
} }
else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") { else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") {
mWindow->queueInfoPopup("CAN'T ADD ENTRIES THAT ARE NOT COUNTED " mWindow->queueInfoPopup(_("CAN'T ADD ENTRIES THAT ARE NOT COUNTED "
"AS GAMES TO CUSTOM COLLECTIONS", "AS GAMES TO CUSTOM COLLECTIONS"),
4000); 4000);
} }
else if (CollectionSystemsManager::getInstance()->toggleGameInCollection( else if (CollectionSystemsManager::getInstance()->toggleGameInCollection(

View file

@ -543,6 +543,8 @@ std::vector<HelpPrompt> GamelistView::getHelpPrompts()
(Settings::getInstance()->getBool("FavoritesAddButton") || (Settings::getInstance()->getBool("FavoritesAddButton") ||
CollectionSystemsManager::getInstance()->isEditing())) { CollectionSystemsManager::getInstance()->isEditing())) {
std::string prompt {CollectionSystemsManager::getInstance()->getEditingCollection()}; std::string prompt {CollectionSystemsManager::getInstance()->getEditingCollection()};
if (prompt == "Favorites")
prompt = _("Favorites");
if (prompt.length() > 24) if (prompt.length() > 24)
prompt = prompt.substr(0, 22) + "..."; prompt = prompt.substr(0, 22) + "...";
prompts.push_back(HelpPrompt("y", prompt)); prompts.push_back(HelpPrompt("y", prompt));