FlightGear next
menubar.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5
6#include "menubar.hxx"
7#include <Main/locale.hxx>
8#include <Main/globals.hxx>
9
13
17
18std::string
19FGMenuBar::getLocalizedLabel(SGPropertyNode* node)
20{
21 if (!node)
22 return {};
23
24 std::string name = node->getStringValue("name", "");
25 if (!name.empty()) {
26 const auto translated = globals->get_locale()->getLocalizedString(name, "menu");
27 if (!translated.empty())
28 return translated;
29 }
30
31 // return default with fallback to name
32 std::string label = node->getStringValue("label", name.c_str());
33
34 // this can occur if the menu item is missing a <name>
35 if (label.empty()) {
36 SG_LOG(SG_GUI, SG_ALERT, "FGMenuBar::getLocalizedLabel: No <name> defined for:" << node->getPath());
37 return std::string{"<unnamed>"};
38 }
39
40 return label;
41}
42
43// end of menubar.cxx
virtual ~FGMenuBar()
Destructor.
Definition menubar.cxx:14
static std::string getLocalizedLabel(SGPropertyNode *node)
Read a menu label from the menu's property tree.
Definition menubar.cxx:19
const char * name
FGGlobals * globals
Definition globals.cxx:142
FlightGear Localization Support.