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
10
FGMenuBar::FGMenuBar
()
11
{
12
}
13
14
FGMenuBar::~FGMenuBar
()
15
{
16
}
17
18
std::string
19
FGMenuBar::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
FGMenuBar::~FGMenuBar
virtual ~FGMenuBar()
Destructor.
Definition
menubar.cxx:14
FGMenuBar::FGMenuBar
FGMenuBar()
Definition
menubar.cxx:10
FGMenuBar::getLocalizedLabel
static std::string getLocalizedLabel(SGPropertyNode *node)
Read a menu label from the menu's property tree.
Definition
menubar.cxx:19
name
const char * name
Definition
fg_commands.cxx:1136
globals
FGGlobals * globals
Definition
globals.cxx:142
globals.hxx
locale.hxx
FlightGear Localization Support.
menubar.hxx
src
GUI
menubar.cxx
Generated on Tue Jun 3 2025 12:58:39 for FlightGear by
1.13.2