Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-16 13:56:35 +02:00
parent 5e3d07bb56
commit 14b65cb2e4
5 changed files with 72 additions and 58 deletions

View file

@ -668,18 +668,21 @@ void CollectionSystemsManager::setEditMode(const std::string& collectionName, bo
else else
editButton = "'Y'"; editButton = "'Y'";
} }
mWindow->queueInfoPopup("EDITING '" + Utils::String::toUpper(collectionName) + mWindow->queueInfoPopup(
"' COLLECTION, ADD/REMOVE GAMES WITH " + editButton, Utils::String::format(_("EDITING '%s' COLLECTION, ADD/REMOVE GAMES WITH %s"),
10000); Utils::String::toUpper(collectionName).c_str(),
editButton.c_str()),
10000);
} }
} }
void CollectionSystemsManager::exitEditMode(bool showPopup) void CollectionSystemsManager::exitEditMode(bool showPopup)
{ {
if (showPopup) { if (showPopup) {
mWindow->queueInfoPopup("FINISHED EDITING '" + Utils::String::toUpper(mEditingCollection) + mWindow->queueInfoPopup(
"' COLLECTION", Utils::String::format(_("FINISHED EDITING '%s' COLLECTION"),
4000); Utils::String::toUpper(mEditingCollection).c_str()),
4000);
} }
mIsEditingCustom = false; mIsEditingCustom = false;
@ -1037,7 +1040,9 @@ void CollectionSystemsManager::deleteCustomCollection(const std::string& collect
<< configFile << "\""; << configFile << "\"";
#endif #endif
mWindow->queueInfoPopup( mWindow->queueInfoPopup(
"DELETED COLLECTION '" + Utils::String::toUpper(collectionName) + "'", 5000); Utils::String::format(_("DELETED COLLECTION '%s'"),
Utils::String::toUpper(collectionName).c_str()),
5000);
} }
else { else {
LOG(LogError) << "Attempted to delete custom collection \"" + collectionName + "\" " + LOG(LogError) << "Attempted to delete custom collection \"" + collectionName + "\" " +

View file

@ -29,14 +29,13 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
// Finish editing custom collection. // Finish editing custom collection.
if (CollectionSystemsManager::getInstance()->isEditing()) { if (CollectionSystemsManager::getInstance()->isEditing()) {
ComponentListRow row; ComponentListRow row;
row.addElement( const std::string editingText {Utils::String::format(
std::make_shared<TextComponent>( _("FINISH EDITING '%s' COLLECTION"),
"FINISH EDITING '" + Utils::String::toUpper(CollectionSystemsManager::getInstance()->getEditingCollection())
Utils::String::toUpper( .c_str())};
CollectionSystemsManager::getInstance()->getEditingCollection()) + row.addElement(std::make_shared<TextComponent>(editingText, Font::get(FONT_SIZE_MEDIUM),
"' COLLECTION", mMenuColorPrimary),
Font::get(FONT_SIZE_MEDIUM), mMenuColorPrimary), true);
true);
row.makeAcceptInputHandler([this] { row.makeAcceptInputHandler([this] {
CollectionSystemsManager::getInstance()->exitEditMode(); CollectionSystemsManager::getInstance()->exitEditMode();
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
@ -261,11 +260,9 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
std::function<void()> deleteCollectionCall = [this, name] { std::function<void()> deleteCollectionCall = [this, name] {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), getHelpStyle(),
"THIS WILL PERMANENTLY\nDELETE THE COLLECTION\n'" + Utils::String::format(_("THIS WILL PERMANENTLY DELETE THE COLLECTION\n'%s'"),
Utils::String::toUpper(name) + Utils::String::toUpper(name).c_str()),
"'\n" _("PROCEED"),
"ARE YOU SURE?",
"YES",
[this, name] { [this, name] {
if (CollectionSystemsManager::getInstance()->isEditing()) if (CollectionSystemsManager::getInstance()->isEditing())
CollectionSystemsManager::getInstance()->exitEditMode(); CollectionSystemsManager::getInstance()->exitEditMode();
@ -300,7 +297,10 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
CollectionSystemsManager::getInstance()->deleteCustomCollection(name); CollectionSystemsManager::getInstance()->deleteCustomCollection(name);
return true; return true;
}, },
"NO", [] { return false; })); _("CANCEL"), [] { return false; }, "", nullptr, nullptr, false, true,
(mRenderer->getIsVerticalOrientation() ?
0.43f :
0.28f * (1.778f / mRenderer->getScreenAspectRatio()))));
}; };
row.makeAcceptInputHandler(deleteCollectionCall); row.makeAcceptInputHandler(deleteCollectionCall);
auto customCollection = std::make_shared<TextComponent>( auto customCollection = std::make_shared<TextComponent>(

View file

@ -174,7 +174,7 @@ GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
mSystem->getRootFolder()->getChildren().size() == 0 && !mIsCustomCollectionGroup && mSystem->getRootFolder()->getChildren().size() == 0 && !mIsCustomCollectionGroup &&
!mIsCustomCollection) { !mIsCustomCollection) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>("THIS SYSTEM HAS NO GAMES", row.addElement(std::make_shared<TextComponent>(_("THIS SYSTEM HAS NO GAMES"),
Font::get(FONT_SIZE_MEDIUM), Font::get(FONT_SIZE_MEDIUM),
mMenuColorPrimary), mMenuColorPrimary),
true); true);
@ -186,7 +186,7 @@ GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
if (CollectionSystemsManager::getInstance()->getEditingCollection() != if (CollectionSystemsManager::getInstance()->getEditingCollection() !=
getGamelist()->getCursor()->getSystem()->getName()) { getGamelist()->getCursor()->getSystem()->getName()) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>("ADD/REMOVE GAMES TO THIS COLLECTION", row.addElement(std::make_shared<TextComponent>(_("ADD/REMOVE GAMES TO THIS COLLECTION"),
Font::get(FONT_SIZE_MEDIUM), Font::get(FONT_SIZE_MEDIUM),
mMenuColorPrimary), mMenuColorPrimary),
true); true);
@ -197,15 +197,14 @@ GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
if (UIModeController::getInstance()->isUIModeFull() && if (UIModeController::getInstance()->isUIModeFull() &&
CollectionSystemsManager::getInstance()->isEditing()) { CollectionSystemsManager::getInstance()->isEditing()) {
const std::string editingText {Utils::String::format(
_("FINISH EDITING '%s' COLLECTION"),
Utils::String::toUpper(CollectionSystemsManager::getInstance()->getEditingCollection())
.c_str())};
row.elements.clear(); row.elements.clear();
row.addElement( row.addElement(std::make_shared<TextComponent>(editingText, Font::get(FONT_SIZE_MEDIUM),
std::make_shared<TextComponent>( mMenuColorPrimary),
"FINISH EDITING '" + true);
Utils::String::toUpper(
CollectionSystemsManager::getInstance()->getEditingCollection()) +
"' COLLECTION",
Font::get(FONT_SIZE_MEDIUM), mMenuColorPrimary),
true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::exitEditMode, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::exitEditMode, this));
mMenu.addRow(row); mMenu.addRow(row);
} }
@ -254,7 +253,7 @@ GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
// Buttons. The logic to apply or cancel settings are handled by the destructor. // Buttons. The logic to apply or cancel settings are handled by the destructor.
if ((!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() == 0) || if ((!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() == 0) ||
system->getName() == "recent") { system->getName() == "recent") {
mMenu.addButton("CLOSE", "close", [&] { mMenu.addButton(_("CLOSE"), _("close"), [&] {
mCancelled = true; mCancelled = true;
delete this; delete this;
}); });

View file

@ -581,7 +581,9 @@ bool GuiThemeDownloader::renameDirectory(const std::string& path, const std::str
if (renameStatus) { if (renameStatus) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), "COULDN'T RENAME DIRECTORY \"" + path + "\", PERMISSION PROBLEMS?", getHelpStyle(),
Utils::String::format(_("COULDN'T RENAME DIRECTORY \"%s\"\nPERMISSION PROBLEMS?"),
path.c_str()),
_("OK"), [] { return; }, "", nullptr, "", nullptr, nullptr, true)); _("OK"), [] { return; }, "", nullptr, "", nullptr, nullptr, true));
return true; return true;
} }
@ -773,11 +775,12 @@ void GuiThemeDownloader::populateGUI()
if (theme.manuallyDownloaded || theme.invalidRepository) { if (theme.manuallyDownloaded || theme.invalidRepository) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), getHelpStyle(),
"IT SEEMS AS IF THIS THEME HAS BEEN MANUALLY DOWNLOADED INSTEAD OF VIA " Utils::String::format(
"THIS THEME DOWNLOADER. A FRESH DOWNLOAD IS REQUIRED AND THE OLD THEME " _("IT SEEMS AS IF THIS THEME HAS BEEN MANUALLY DOWNLOADED INSTEAD OF VIA "
"DIRECTORY \"" + "THIS THEME DOWNLOADER. A FRESH DOWNLOAD IS REQUIRED AND THE OLD THEME "
theme.reponame + theme.manualExtension + "\" WILL BE RENAMED TO \"" + "DIRECTORY \"%s\" WILL BE RENAMED TO \"%s_DISABLED\""),
theme.reponame + theme.manualExtension + "_DISABLED\"", std::string {theme.reponame + theme.manualExtension}.c_str(),
std::string {theme.reponame + theme.manualExtension}.c_str()),
_("PROCEED"), _("PROCEED"),
[this, theme] { [this, theme] {
if (renameDirectory(mThemeDirectory + theme.reponame + if (renameDirectory(mThemeDirectory + theme.reponame +
@ -800,12 +803,13 @@ void GuiThemeDownloader::populateGUI()
else if (theme.corruptRepository) { else if (theme.corruptRepository) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), getHelpStyle(),
"IT SEEMS AS IF THIS THEME REPOSITORY IS CORRUPT, WHICH COULD HAVE BEEN CAUSED " Utils::String::format(
"BY AN INTERRUPTION OF A PREVIOUS DOWNLOAD OR UPDATE, FOR EXAMPLE IF THE ES-DE " _("IT SEEMS AS IF THIS THEME REPOSITORY IS CORRUPT, WHICH COULD HAVE BEEN "
"PROCESS WAS KILLED. A FRESH DOWNLOAD IS REQUIRED AND THE OLD THEME DIRECTORY " "CAUSED BY AN INTERRUPTION OF A PREVIOUS DOWNLOAD OR UPDATE, FOR EXAMPLE "
"\"" + "IF THE ES-DE PROCESS WAS KILLED. A FRESH DOWNLOAD IS REQUIRED AND THE "
theme.reponame + theme.manualExtension + "\" WILL BE RENAMED TO \"" + "OLD THEME DIRECTORY \"%s\" WILL BE RENAMED TO \"%s_CORRUPT_DISABLED\""),
theme.reponame + theme.manualExtension + "_CORRUPT_DISABLED\"", std::string {theme.reponame + theme.manualExtension}.c_str(),
std::string {theme.reponame + theme.manualExtension}.c_str()),
_("PROCEED"), _("PROCEED"),
[this, theme] { [this, theme] {
if (renameDirectory(mThemeDirectory + theme.reponame + if (renameDirectory(mThemeDirectory + theme.reponame +
@ -828,11 +832,13 @@ void GuiThemeDownloader::populateGUI()
else if (theme.shallowRepository) { else if (theme.shallowRepository) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), getHelpStyle(),
"IT SEEMS AS IF THIS IS A SHALLOW REPOSITORY WHICH MEANS THAT IT HAS BEEN " Utils::String::format(
"DOWNLOADED USING SOME OTHER TOOL THAN THIS THEME DOWNLOADER. A FRESH DOWNLOAD " _("IT SEEMS AS IF THIS IS A SHALLOW REPOSITORY WHICH MEANS THAT IT HAS "
"IS REQUIRED AND THE OLD THEME DIRECTORY \"" + "BEEN DOWNLOADED USING SOME OTHER TOOL THAN THIS THEME DOWNLOADER. A "
theme.reponame + theme.manualExtension + "\" WILL BE RENAMED TO \"" + "FRESH DOWNLOAD IS REQUIRED AND THE OLD THEME DIRECTORY \"%s\" WILL BE "
theme.reponame + theme.manualExtension + "_DISABLED\"", "RENAMED TO \"%s_DISABLED\""),
std::string {theme.reponame + theme.manualExtension}.c_str(),
std::string {theme.reponame + theme.manualExtension}.c_str()),
_("PROCEED"), _("PROCEED"),
[this, theme] { [this, theme] {
if (renameDirectory(mThemeDirectory + theme.reponame + if (renameDirectory(mThemeDirectory + theme.reponame +
@ -855,9 +861,10 @@ void GuiThemeDownloader::populateGUI()
else if (theme.hasLocalChanges) { else if (theme.hasLocalChanges) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), getHelpStyle(),
"THEME REPOSITORY \"" + theme.reponame + Utils::String::format(
"\" CONTAINS LOCAL CHANGES. PROCEED TO OVERWRITE YOUR CHANGES " _("THEME REPOSITORY \"%s\" CONTAINS LOCAL CHANGES. PROCEED TO OVERWRITE "
"OR CANCEL TO SKIP ALL UPDATES FOR THIS THEME", "YOUR CHANGES OR CANCEL TO SKIP ALL UPDATES FOR THIS THEME"),
std::string {theme.reponame}.c_str()),
_("PROCEED"), _("PROCEED"),
[this, theme] { [this, theme] {
std::promise<bool>().swap(mPromise); std::promise<bool>().swap(mPromise);

View file

@ -15,6 +15,7 @@
#include "Window.h" #include "Window.h"
#include "resources/ResourceManager.h" #include "resources/ResourceManager.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/LocalizationUtil.h"
#include "utils/PlatformUtil.h" #include "utils/PlatformUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
@ -822,9 +823,10 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)
if (window != nullptr) { if (window != nullptr) {
window->queueInfoPopup( window->queueInfoPopup(
"ADDED INPUT DEVICE '" + Utils::String::format(
Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID]))) + _("ADDED INPUT DEVICE '%s'"),
"'", Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID])))
.c_str()),
4000); 4000);
} }
@ -870,9 +872,10 @@ void InputManager::removeControllerByJoystickID(Window* window, SDL_JoystickID j
if (window != nullptr) { if (window != nullptr) {
window->queueInfoPopup( window->queueInfoPopup(
"REMOVED INPUT DEVICE '" + Utils::String::format(
Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID]))) + _("REMOVED INPUT DEVICE '%s'"),
"'", Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID])))
.c_str()),
4000); 4000);
} }