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()),
favoritesSorting);
mWindow->queueInfoPopup(
"DISABLED '" +
Utils::String::format(
_("DISABLED '%s' IN '%s'"),
Utils::String::toUpper(
Utils::String::removeParenthesis(file->getName())) +
"' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'",
Utils::String::removeParenthesis(file->getName()))
.c_str(),
Utils::String::toUpper(sysData.system->getName()).c_str()),
4000);
}
else {
@ -786,14 +788,19 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
ViewController::getInstance()->reloadGamelistView(
mAutoCollectionSystemsData["favorites"].system);
}
std::string sysTemp {sysName};
if (sysTemp == "Favorites")
sysTemp = _("Favorites");
if (adding) {
mWindow->queueInfoPopup("ADDED '" + Utils::String::toUpper(name) + "' TO '" +
Utils::String::toUpper(sysName) + "'",
mWindow->queueInfoPopup(Utils::String::format(_("ADDED '%s' TO '%s'"),
Utils::String::toUpper(name).c_str(),
Utils::String::toUpper(sysTemp).c_str()),
4000);
}
else {
mWindow->queueInfoPopup("REMOVED '" + Utils::String::toUpper(name) + "' FROM '" +
Utils::String::toUpper(sysName) + "'",
mWindow->queueInfoPopup(Utils::String::format(_("REMOVED '%s' FROM '%s'"),
Utils::String::toUpper(name).c_str(),
Utils::String::toUpper(sysTemp).c_str()),
4000);
}
return true;
@ -825,7 +832,7 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
FileData* rootFolder {sys->getRootFolder()};
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*> gamesListRandom;

View file

@ -593,7 +593,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
else if (newVal == "" &&
(currentKey == "developer" || currentKey == "publisher" ||
currentKey == "genre" || currentKey == "players")) {
ed->setValue("unknown");
ed->setValue(_("unknown"));
if (originalValue == "unknown")
ed->setColor(mMenuColorPrimary);
else
@ -601,10 +601,17 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
}
else {
ed->setValue(newVal);
if (newVal == originalValue)
if ((currentKey == "developer" || currentKey == "publisher" ||
currentKey == "genre" || currentKey == "players") &&
newVal == _("unknown") && newVal == _(originalValue.c_str())) {
ed->setColor(mMenuColorPrimary);
else
ed->setColor(mMenuColorBlue);
}
else {
if (newVal == originalValue)
ed->setColor(mMenuColorPrimary);
else
ed->setColor(mMenuColorBlue);
}
}
};
@ -645,7 +652,12 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
ed->setValue(ViewController::EXCLAMATION_CHAR + " " + mMetaData->get(it->key));
}
else {
ed->setValue(mMetaData->get(it->key));
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));
}
mEditors.push_back(ed);
@ -784,7 +796,7 @@ void GuiMetaDataEd::save()
bool setGameAsCounted {false};
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
// skipping the custom collections sortname field (which we do if not editing the
// game from within a custom collection gamelist).
@ -803,7 +815,7 @@ void GuiMetaDataEd::save()
continue;
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")
mMetaData->set(key, shortName);
continue;
@ -819,7 +831,13 @@ void GuiMetaDataEd::save()
setGameAsCounted = true;
}
mMetaData->set(key, mEditors.at(i)->getValue());
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());
}
}
// If hidden games are not shown and the hide flag was set for the entry, then write the
@ -980,6 +998,11 @@ void GuiMetaDataEd::close()
std::string mMetaDataValue {mMetaData->get(key)};
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() != "") {
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
if (shortName == "unknown" || mMetaDataValue == shortName)

View file

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

View file

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

View file

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