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

View file

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

View file

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

View file

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

View file

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