Fix translation problems in random GP screen

This commit is contained in:
Marc Coll Carrillo 2014-12-24 13:45:44 +01:00 committed by Deve
parent 3a1b0bc351
commit 9e6cd2a958
5 changed files with 30 additions and 17 deletions

View File

@ -67,7 +67,7 @@ void GrandPrixData::createRandomGP(const unsigned int number_of_tracks,
{
m_filename = "Random GP - Not loaded from a file!";
m_id = "random";
m_name = "Random Grand Prix";
m_name = _("Random Grand Prix");
m_editable = false;
m_group = GP_NONE;
m_reverse_type = use_reverse;

View File

@ -125,7 +125,7 @@ void EnterGPNameDialog::validateName()
label->setText(_("Name is empty."), false);
SFXManager::get()->quickSound("anvil");
}
else if (grand_prix_manager->existsName(name) || name == "Random Grand Prix")
else if (grand_prix_manager->existsName(name) || name == _("Random Grand Prix"))
{
// check for duplicate names
label->setText(_("Another grand prix with this name already exists."), false);

View File

@ -177,14 +177,17 @@ void GPInfoScreen::init()
// We have to recreate the group spinner, but a new group might have
// been added or deleted since the last time this screen was shown.
m_group_spinner->clearLabels();
m_group_spinner->addLabel("all");
int index_standard=0;
const std::vector<std::string>& groups = track_manager->getAllTrackGroups();
m_group_names.clear();
m_group_names.push_back("all");
for (unsigned int i = 0; i < groups.size(); i++)
m_group_names.push_back(groups[i]);
m_group_spinner->clearLabels();
int index_standard=0;
for (unsigned int i = 0; i < m_group_names.size(); i++)
{
m_group_spinner->addLabel(stringw(groups[i].c_str()));
if (groups[i] == "standard")
m_group_spinner->addLabel(_(m_group_names[i].c_str()));
if (m_group_names[i] == "standard")
index_standard = i + 1;
}
// Try to keep a previously selected group value
@ -194,12 +197,13 @@ void GPInfoScreen::init()
m_group_name = "standard";
}
else
m_group_name = stringc(m_group_spinner->getStringValue().c_str()).c_str();
m_group_name = stringc(m_group_names[m_group_spinner->getValue()].c_str()).c_str();
m_max_num_tracks = getMaxNumTracks(m_group_name);
m_num_tracks_spinner->setMax(m_max_num_tracks);
if(m_num_tracks_spinner->getValue() > m_max_num_tracks)
if(m_num_tracks_spinner->getValue() > m_max_num_tracks ||
m_num_tracks_spinner->getValue() < 1)
{
m_num_tracks_spinner->setValue(m_max_num_tracks);
}
@ -312,10 +316,10 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
} // name=="buttons"
else if (name=="group-spinner")
{
m_group_name = stringc(m_group_spinner->getStringValue()).c_str();
m_group_name = stringc(m_group_names[m_group_spinner->getValue()].c_str()).c_str();
m_max_num_tracks = getMaxNumTracks(m_group_name);
m_num_tracks_spinner->setMax(m_max_num_tracks);
if (m_num_tracks_spinner->getValue() > m_max_num_tracks)
m_num_tracks_spinner->setValue(m_max_num_tracks);

View File

@ -23,6 +23,8 @@
#include "guiengine/screen.hpp"
#include "race/grand_prix_data.hpp"
#include <vector>
class GrandPrixData;
namespace GUIEngine
@ -47,16 +49,19 @@ private:
/** Spinner for number of tracks (in case of random GP). */
GUIEngine::SpinnerWidget *m_num_tracks_spinner;
/** Spinner for number of AI karts. */
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
/** The currently selected group name. */
std::string m_group_name;
/** The untranslated group names, used as internal IDs */
std::vector<std::string> m_group_names;
/** Number of available tracks */
int m_max_num_tracks;
/** Get number of available tracks for random GPs */
int getMaxNumTracks(std::string group);

View File

@ -143,14 +143,18 @@ void TracksScreen::beforeAddingWidget()
if (group_amount > 1)
{
//I18N: name of the tab that will show tracks from all groups
tabs->addTextChild( _("All"), ALL_TRACK_GROUPS_ID );
tabs->addTextChild( _(ALL_TRACK_GROUPS_ID), ALL_TRACK_GROUPS_ID );
}
// Make group names being picked up by gettext
#define FOR_GETTEXT_ONLY(x)
//I18N: track group name
FOR_GETTEXT_ONLY( _("all") )
//I18N: track group name
FOR_GETTEXT_ONLY( _("standard") )
//I18N: track group name
FOR_GETTEXT_ONLY( _("nextgen") )
//I18N: track group name
FOR_GETTEXT_ONLY( _("Add-Ons") )
// add behind the other categories
@ -214,7 +218,7 @@ void TracksScreen::init()
// Random GP
std::vector<std::string> screenshots;
screenshots.push_back(file_manager->getAsset(FileManager::GUI, "main_help.png"));
gps_widget->addAnimatedItem(translations->fribidize("Random Grand Prix"),
gps_widget->addAnimatedItem(translations->fribidize(_("Random Grand Prix")),
"Random Grand Prix",
screenshots, 1.5f, 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);