Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-14 16:48:31 +02:00
parent d2d4b6d45c
commit 557748970a
5 changed files with 77 additions and 71 deletions

View file

@ -768,8 +768,8 @@ void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings)
_("OK"), nullptr, "", nullptr, "", nullptr, nullptr, false,
true,
(mRenderer->getIsVerticalOrientation() ?
0.78f :
0.48f * (1.778f / mRenderer->getScreenAspectRatio()))));
0.80f :
0.50f * (1.778f / mRenderer->getScreenAspectRatio()))));
return;
}

View file

@ -22,6 +22,7 @@
#include "components/TextComponent.h"
#include "guis/GuiMsgBox.h"
#include "guis/GuiScraperSearch.h"
#include "utils/LocalizationUtil.h"
GuiScraperMulti::GuiScraperMulti(
const std::pair<std::queue<ScraperSearchParams>, std::map<SystemData*, int>>& searches,
@ -48,11 +49,11 @@ GuiScraperMulti::GuiScraperMulti(
mQueueCountPerSystem[(*it).first] = std::make_pair(0, (*it).second);
// Set up grid.
mTitle = std::make_shared<TextComponent>("SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE),
mTitle = std::make_shared<TextComponent>(_("SCRAPING IN PROGRESS"), Font::get(FONT_SIZE_LARGE),
mMenuColorTitle, ALIGN_CENTER);
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
mSystem = std::make_shared<TextComponent>("SYSTEM", Font::get(FONT_SIZE_MEDIUM),
mSystem = std::make_shared<TextComponent>(_("SYSTEM"), Font::get(FONT_SIZE_MEDIUM),
mMenuColorPrimary, ALIGN_CENTER);
mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
@ -105,7 +106,8 @@ GuiScraperMulti::GuiScraperMulti(
std::vector<std::shared_ptr<ButtonComponent>> buttons;
if (mApproveResults) {
buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
buttons.push_back(
std::make_shared<ButtonComponent>(_("REFINE SEARCH"), _("refine search"), [&] {
// Check whether we should allow a refine of the game name.
if (!mSearchComp->getAcceptedResult()) {
bool allowRefine = false;
@ -136,7 +138,7 @@ GuiScraperMulti::GuiScraperMulti(
}
}));
buttons.push_back(std::make_shared<ButtonComponent>("SKIP", "skip game", [&] {
buttons.push_back(std::make_shared<ButtonComponent>(_("SKIP"), _("skip game"), [&] {
// Skip game, unless the result has already been accepted.
if (!mSearchComp->getAcceptedResult()) {
skip();
@ -145,7 +147,7 @@ GuiScraperMulti::GuiScraperMulti(
}));
}
buttons.push_back(std::make_shared<ButtonComponent>("STOP", "stop",
buttons.push_back(std::make_shared<ButtonComponent>(_("STOP"), _("stop"),
std::bind(&GuiScraperMulti::finish, this)));
mButtonGrid = MenuComponent::makeButtonGrid(buttons);
@ -308,7 +310,7 @@ void GuiScraperMulti::finish()
{
std::stringstream ss;
if (mTotalSuccessful == 0) {
ss << "NO GAMES WERE SCRAPED";
ss << _("NO GAMES WERE SCRAPED");
}
else {
ss << mTotalSuccessful << " GAME" << ((mTotalSuccessful > 1) ? "S" : "")
@ -321,7 +323,7 @@ void GuiScraperMulti::finish()
// Pressing either OK or using the back button should delete us.
mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), ss.str(), "OK",
getHelpStyle(), ss.str(), _("OK"),
[&] {
mIsProcessing = false;
delete this;

View file

@ -32,6 +32,7 @@
#include "guis/GuiTextEditKeyboardPopup.h"
#include "guis/GuiTextEditPopup.h"
#include "resources/Font.h"
#include "utils/LocalizationUtil.h"
#include "utils/StringUtil.h"
GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount, int rowCount)
@ -103,18 +104,18 @@ GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount, in
if (mScrapeRatings)
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>("RATING:", font, mdLblColor), mMD_Rating, false));
std::make_shared<TextComponent>(_("RATING:"), font, mdLblColor), mMD_Rating, false));
mMD_Pairs.push_back(MetaDataPair(std::make_shared<TextComponent>("RELEASED:", font, mdLblColor),
mMD_ReleaseDate));
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>("DEVELOPER:", font, mdLblColor), mMD_Developer));
std::make_shared<TextComponent>(_("RELEASED:"), font, mdLblColor), mMD_ReleaseDate));
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>("PUBLISHER:", font, mdLblColor), mMD_Publisher));
std::make_shared<TextComponent>(_("DEVELOPER:"), font, mdLblColor), mMD_Developer));
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>(_("PUBLISHER:"), font, mdLblColor), mMD_Publisher));
mMD_Pairs.push_back(
MetaDataPair(std::make_shared<TextComponent>("GENRE:", font, mdLblColor), mMD_Genre));
mMD_Pairs.push_back(
MetaDataPair(std::make_shared<TextComponent>("PLAYERS:", font, mdLblColor), mMD_Players));
MetaDataPair(std::make_shared<TextComponent>(_("GENRE:"), font, mdLblColor), mMD_Genre));
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>(_("PLAYERS:"), font, mdLblColor), mMD_Players));
// If no rating is being scraped, add a filler to make sure that the fonts keep the same
// size so the GUI looks consistent.
@ -428,7 +429,7 @@ void GuiScraperSearch::onSearchDone(std::vector<ScraperSearchResult>& results)
mFoundGame = false;
ComponentListRow row;
row.addElement(std::make_shared<TextComponent>("NO GAMES FOUND", font, color), true);
row.addElement(std::make_shared<TextComponent>(_("NO GAMES FOUND"), font, color), true);
if (mSkipCallback)
row.makeAcceptInputHandler(mSkipCallback);
@ -578,16 +579,16 @@ void GuiScraperSearch::onSearchError(const std::string& error,
if (mScrapeCount > 1) {
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), _("RETRY"),
std::bind(&GuiScraperSearch::search, this, mLastSearch),
"SKIP", mSkipCallback, "CANCEL", mCancelCallback, nullptr,
true));
_("SKIP"), mSkipCallback, _("CANCEL"), mCancelCallback,
nullptr, true));
}
else {
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), _("RETRY"),
std::bind(&GuiScraperSearch::search, this, mLastSearch),
"CANCEL", mCancelCallback, "", nullptr, nullptr, true));
_("CANCEL"), mCancelCallback, "", nullptr, nullptr, true));
}
}
@ -1028,14 +1029,14 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
searchString = Utils::String::replace(searchString, "_", " ");
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), 0.0f, "REFINE SEARCH",
searchString, searchForFunc, false, "SEARCH",
"SEARCH USING REFINED NAME?"));
mWindow->pushGui(new GuiTextEditKeyboardPopup(
getHelpStyle(), 0.0f, _("REFINE SEARCH"), searchString, searchForFunc, false,
_("SEARCH"), _("SEARCH USING REFINED NAME?")));
}
else {
mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "REFINE SEARCH", searchString,
searchForFunc, false, "SEARCH",
"SEARCH USING REFINED NAME?"));
mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), _("REFINE SEARCH"), searchString,
searchForFunc, false, _("SEARCH"),
_("SEARCH USING REFINED NAME?")));
}
}
@ -1126,15 +1127,15 @@ std::vector<HelpPrompt> GuiScraperSearch::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
prompts.push_back(HelpPrompt("y", "refine search"));
prompts.push_back(HelpPrompt("y", _("refine search")));
// Only show the skip prompt during multi-scraping.
if (mSkipCallback != nullptr)
prompts.push_back(HelpPrompt("x", "skip"));
prompts.push_back(HelpPrompt("x", _("skip")));
if (mFoundGame && (mRefinedSearch || mSearchType != SEMIAUTOMATIC_MODE ||
(mSearchType == SEMIAUTOMATIC_MODE && mScraperResults.size() > 1)))
prompts.push_back(HelpPrompt("a", "accept result"));
prompts.push_back(HelpPrompt("a", _("accept result")));
return prompts;
}

View file

@ -16,6 +16,7 @@
#include "components/ButtonComponent.h"
#include "components/MenuComponent.h"
#include "components/TextComponent.h"
#include "utils/LocalizationUtil.h"
GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
std::function<void(const ScraperSearchResult&)> doneFunc,
@ -84,7 +85,8 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
// Buttons
std::vector<std::shared_ptr<ButtonComponent>> buttons;
buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
buttons.push_back(
std::make_shared<ButtonComponent>(_("REFINE SEARCH"), _("refine search"), [&] {
// Refine the search, unless the result has already been accepted.
if (!mSearch->getAcceptedResult()) {
// Copy any search refine that may have been previously entered by opening
@ -94,7 +96,7 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
mGrid.resetCursor();
}
}));
buttons.push_back(std::make_shared<ButtonComponent>("CANCEL", "cancel", [&] {
buttons.push_back(std::make_shared<ButtonComponent>(_("CANCEL"), _("cancel"), [&] {
if (mSearch->getSavedNewMedia()) {
// If the user aborted the scraping but there was still some media downloaded,
// then flag to GuiMetaDataEd that the image and marquee textures need to be
@ -194,7 +196,7 @@ void GuiScraperSingle::update(int deltaTime)
std::vector<HelpPrompt> GuiScraperSingle::getHelpPrompts()
{
std::vector<HelpPrompt> prompts {mGrid.getHelpPrompts()};
prompts.push_back(HelpPrompt("b", "back (cancel)"));
prompts.push_back(HelpPrompt("b", _("back (cancel)")));
return prompts;
}

View file

@ -10,13 +10,14 @@
#include "components/AnimatedImageComponent.h"
#include "components/ImageComponent.h"
#include "utils/LocalizationUtil.h"
BusyComponent::BusyComponent()
: mBackground {":/graphics/frame.png"}
, mGrid {glm::ivec2 {5, 3}}
{
mAnimation = std::make_shared<AnimatedImageComponent>();
mText = std::make_shared<TextComponent>("WORKING...", Font::get(FONT_SIZE_MEDIUM),
mText = std::make_shared<TextComponent>(_("WORKING..."), Font::get(FONT_SIZE_MEDIUM),
mMenuColorPrimary);
// Col 0 = animation, col 1 = spacer, col 2 = text.