Added localization support to parts of the application

This commit is contained in:
Leon Styhre 2024-07-16 16:50:46 +02:00
parent c8259aa792
commit 062288ad07
3 changed files with 74 additions and 61 deletions

View file

@ -720,22 +720,26 @@ void GuiMenu::openUIOptions()
return;
}
else if (selectedMode != "full") {
std::string msg {"YOU ARE CHANGING THE UI TO THE RESTRICTED MODE\n'" +
Utils::String::toUpper(selectedMode) + "'\n"};
std::string msg;
if (selectedMode == "kiosk") {
msg.append("THIS WILL HIDE MOST MENU OPTIONS TO PREVENT\n");
msg.append("CHANGES TO THE SYSTEM\n");
msg = Utils::String::format(
_("THIS CHANGES THE UI TO THE RESTRICTED MODE\n'KIOSK'\n"
"THIS WILL HIDE MOST MENU OPTIONS\n"
"TO UNLOCK AND RETURN TO THE FULL UI, ENTER THIS CODE:\n%s\n\n"
"DO YOU WANT TO PROCEED?"),
UIModeController::getInstance()->getFormattedPassKeyStr().c_str());
}
else {
msg.append("THIS WILL LIMIT THE AVAILABLE GAMES TO THE ONES\n");
msg.append("FLAGGED SUITABLE FOR CHILDREN\n");
msg = Utils::String::format(
_("THIS CHANGES THE UI TO THE RESTRICTED MODE\n'KID'\n"
"THIS ONLY ENABLES GAMES THAT HAVE BEEN FLAGGED\n"
"AS SUITABLE FOR CHILDREN\n"
"TO UNLOCK AND RETURN TO THE FULL UI, ENTER THIS CODE:\n%s\n\n"
"DO YOU WANT TO PROCEED?"),
UIModeController::getInstance()->getFormattedPassKeyStr().c_str());
}
msg.append("TO UNLOCK AND RETURN TO THE FULL UI, ENTER THIS CODE: \n")
.append(UIModeController::getInstance()->getFormattedPassKeyStr())
.append("\n\n")
.append("DO YOU WANT TO PROCEED?");
mWindow->pushGui(new GuiMsgBox(
this->getHelpStyle(), msg, "YES",
this->getHelpStyle(), msg, _("YES"),
[this, selectedMode] {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '"
<< selectedMode << "'.";
@ -762,7 +766,7 @@ void GuiMenu::openUIOptions()
false);
mWindow->invalidateCachedBackground();
},
"NO", nullptr, "", nullptr, nullptr, true));
_("NO"), nullptr, "", nullptr, nullptr, true));
}
else {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << selectedMode

View file

@ -322,12 +322,21 @@ private:
std::stringstream ss;
// For special situations, allow the "selected" text to be overridden to a custom value.
if (mOverrideMultiText != "")
if (mOverrideMultiText != "") {
ss << mOverrideMultiText;
else if (mMultiShowTotal)
ss << getSelectedObjects().size() << " (OF " << mEntries.size() << ") SELECTED";
else
ss << getSelectedObjects().size() << " SELECTED";
}
else if (mMultiShowTotal) {
const std::string numString {Utils::String::format(
_("%i (OF %i)"), getSelectedObjects().size(), mEntries.size())};
ss << Utils::String::format(
_n("%s SELECTED", "%s SELECTED", getSelectedObjects().size()),
numString.c_str());
}
else {
ss << Utils::String::format(
_n("%i SELECTED", "%i SELECTED", getSelectedObjects().size()),
getSelectedObjects().size());
}
mText.setText(ss.str());
mText.setSize(0, mText.getSize().y);

View file

@ -40,41 +40,6 @@
#include "guis/GuiMsgBox.h"
#include "utils/StringUtil.h"
// clang-format off
std::vector<std::vector<std::string>> kbBaseUS {
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "DEL"},
{"!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "DEL"},
{"¡", "²", "³", "¤", "", "¼", "½", "¾", "", "", "¥", "×", "DEL"},
{"¹", "", "", "£", "", "", "", "", "", "", "", "÷", "DEL"},
{"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "OK"},
{"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}", "OK"},
{"ä", "å", "é", "®", "þ", "ü", "ú", "í", "ó", "ö", "«", "»", "OK"},
{"Ä", "Å", "É", "", "Þ", "Ü", "Ú", "Í", "Ó", "Ö", "", "", "OK"},
{"a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\\", "-rowspan-"},
{"A", "S", "D", "F", "G", "H", "J", "K", "L", ":", "\"", "|", "-rowspan-"},
{"á", "ß", "ð", "", "", "", "", "", "ø", "", "´", "¬", "-rowspan-"},
{"Á", "§", "Ð", "", "", "", "", "", "Ø", "°", "¨", "¦", "-rowspan-"},
{"`", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "ALT", "-colspan-"},
{"~", "Z", "X", "C", "V", "B", "N", "M", "<", ">", "?", "ALT", "-colspan-"},
{"", "æ", "", "©", "", "", "ñ", "µ", "ç", "", "¿", "ALT", "-colspan-"},
{"", "Æ", "", "¢", "", "", "Ñ", "Μ", "Ç", "", "", "ALT", "-colspan-"}};
std::vector<std::vector<std::string>> kbLastRowNormal {
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"}};
std::vector<std::vector<std::string>> kbLastRowLoad {
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "LOAD", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "LOAD", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "LOAD", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"},
{"SHIFT", "-colspan-", "SPACE", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "LOAD", "-colspan-", "CLEAR", "-colspan-", "CANCEL", "-colspan-"}};
// clang-format on
GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
const HelpStyle& helpstyle,
const float verticalPosition,
@ -111,6 +76,41 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
, mNavigationRepeatDirX {0}
, mNavigationRepeatDirY {0}
{
// clang-format off
std::vector<std::vector<std::string>> kbBaseUS {
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "DEL"},
{"!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "DEL"},
{"¡", "²", "³", "¤", "", "¼", "½", "¾", "", "", "¥", "×", "DEL"},
{"¹", "", "", "£", "", "", "", "", "", "", "", "÷", "DEL"},
{"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "OK"},
{"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}", "OK"},
{"ä", "å", "é", "®", "þ", "ü", "ú", "í", "ó", "ö", "«", "»", "OK"},
{"Ä", "Å", "É", "", "Þ", "Ü", "Ú", "Í", "Ó", "Ö", "", "", "OK"},
{"a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\\", "-rowspan-"},
{"A", "S", "D", "F", "G", "H", "J", "K", "L", ":", "\"", "|", "-rowspan-"},
{"á", "ß", "ð", "", "", "", "", "", "ø", "", "´", "¬", "-rowspan-"},
{"Á", "§", "Ð", "", "", "", "", "", "Ø", "°", "¨", "¦", "-rowspan-"},
{"`", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "ALT", "-colspan-"},
{"~", "Z", "X", "C", "V", "B", "N", "M", "<", ">", "?", "ALT", "-colspan-"},
{"", "æ", "", "©", "", "", "ñ", "µ", "ç", "", "¿", "ALT", "-colspan-"},
{"", "Æ", "", "¢", "", "", "Ñ", "Μ", "Ç", "", "", "ALT", "-colspan-"}};
std::vector<std::vector<std::string>> kbLastRowNormal {
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"}};
std::vector<std::vector<std::string>> kbLastRowLoad {
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("LOAD"), "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("LOAD"), "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("LOAD"), "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"},
{"SHIFT", "-colspan-", _("SPACE"), "-colspan-", "-colspan-", "-colspan-", "-colspan-", _("LOAD"), "-colspan-", _("CLEAR"), "-colspan-", _("CANCEL"), "-colspan-"}};
// clang-format on
addChild(&mBackground);
addChild(&mGrid);
@ -185,7 +185,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
alted = OK_SYMBOL;
altshifted = OK_SYMBOL;
}
else if (lower == "SPACE") {
else if (lower == _("SPACE")) {
lower = " ";
upper = " ";
alted = " ";
@ -515,12 +515,12 @@ std::vector<HelpPrompt> GuiTextEditKeyboardPopup::getHelpPrompts()
if (prompts.size() > 0 && prompts.front().second == OK_SYMBOL)
prompts.front().second = mAcceptBtnHelpText;
else if (prompts.size() > 0 && prompts.front().second == " ")
prompts.front().second = "SPACE";
else if (prompts.size() > 0 && prompts.front().second == "CLEAR")
prompts.front().second = _("SPACE");
else if (prompts.size() > 0 && prompts.front().second == _("CLEAR"))
prompts.front().second = mClearBtnHelpText;
else if (prompts.size() > 0 && prompts.front().second == "LOAD")
else if (prompts.size() > 0 && prompts.front().second == _("LOAD"))
prompts.front().second = mLoadBtnHelpText;
else if (prompts.size() > 0 && prompts.front().second == "CANCEL")
else if (prompts.size() > 0 && prompts.front().second == _("CANCEL"))
prompts.front().second = mCancelBtnHelpText;
// If a prompt has no value set, then remove it.
@ -677,22 +677,22 @@ std::shared_ptr<ButtonComponent> GuiTextEditKeyboardPopup::makeButton(
mText->stopEditing();
return;
}
else if (key == "SPACE" || key == " ") {
else if (key == _("SPACE") || key == " ") {
mText->startEditing();
mText->textInput(" ");
mText->stopEditing();
return;
}
else if (key == "LOAD") {
else if (key == _("LOAD")) {
mText->setValue(mDefaultValue->getValue());
mText->setCursor(mDefaultValue->getValue().size());
return;
}
else if (key == "CLEAR") {
else if (key == _("CLEAR")) {
mText->setValue("");
return;
}
else if (key == "CANCEL") {
else if (key == _("CANCEL")) {
delete this;
return;
}