Skip to content
Permalink
Browse files

Make editor menu translatable. Part of #667.

  • Loading branch information
Quintus committed Nov 20, 2019
1 parent 436f824 commit 838c72398e4e3e69cfd94d9fa9d7fd6e127f5bc1
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file contains the menu items for the level editor.
If an item is added, be sure to add the item's label to
the list of labels in level_editor.cpp to make xgettext(1)
aware of the new menu entry for translation.
-->
<menu>
<item>
<property name="name" value="---Sprites---" />
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file contains the menu items for the world editor.
If an item is added, be sure to add the item's label to
the list of labels in world_editor.cpp to make xgettext(1)
aware of the new menu entry for translation.
-->
<menu>
<item>
<property name="name" value="---Sprites---" />
@@ -938,6 +938,9 @@ void cEditor::parse_menu_file()
// Burst the tag list into its elements
std::vector<std::string> tags = string_split(tagstr, ";");

// Translate label (translation lists are in the respective editor's cpp file)
name = gettext(name.c_str());

// Prepare informational menu object
cEditor_Menu_Entry* p_entry = new cEditor_Menu_Entry(name);
p_entry->Set_Color(Color(colorstr));
@@ -963,7 +966,7 @@ void cEditor::populate_menu()
std::vector<cEditor_Menu_Entry*>::iterator iter;

for(iter = m_menu_entries.begin(); iter != m_menu_entries.end(); iter++) {
CEGUI::ListboxTextItem* p_item = new CEGUI::ListboxTextItem((*iter)->Get_Name());
CEGUI::ListboxTextItem* p_item = new CEGUI::ListboxTextItem((*iter)->Get_CEGUI_Name());
p_item->setTextColours(CEGUI::ColourRect((*iter)->Get_Color().Get_cegui_Color()));
p_item->setUserData(*iter);
mp_menu_listbox->addItem(p_item);
@@ -30,6 +30,7 @@ namespace TSC {
inline Color Get_Color(){ return m_color; }

inline std::string Get_Name(){ return m_name; }
inline const CEGUI::utf8* Get_CEGUI_Name() { return reinterpret_cast<const CEGUI::utf8*>(m_name.c_str()); }

inline void Set_Header(bool is_header){ m_is_header = is_header; }
inline void Set_Function(bool is_function){ m_is_function = is_function; }
@@ -311,3 +311,50 @@ std::string cEditor_Level::Status_Bar_Ident() const
else
return "--";
}

/* Translations for the level editor's menu entries. This has to match
* the content in data/editor/level_menu.xml. An always-false if is
* used, because the strings are sourced from the XML. This only
* exists here to make xgettext(1) find them. */
#if 0
// TRANS: Level editor left menu's entries follow
static std::string values[] = {_("---Sprites---"),
_("Green Ground"),
_("Desert Ground"),
_("Sand Ground"),
_("Castle Ground"),
_("Cave Ground"),
_("Underground"),
_("Plastic Ground"),
_("Jungle Ground"),
_("Snow Ground"),
_("Blocks"),
_("Clouds"),
_("Hedges"),
_("Trees"),
_("Plants"),
_("Cactus"),
_("Platforms"),
_("Pipes"),
_("Pipe Connectors"),
_("Library"),
_("Hills"),
_("Signs"),
_("Ropes"),
_("Doors"),
_("Bones"),
_("Windows"),
_("Candy"),
_("Stuff"),
_("---Objects---"),
_("Boxes"),
_("Enemies"),
_("Special"),
_("---Functions---"),
_("New"),
_("Load"),
_("Save"),
_("Save as"),
_("Delete"),
_("Settings")};
#endif
@@ -155,3 +155,33 @@ std::string cEditor_World::Status_Bar_Ident() const
else
return "--";
}

/* Translations for the world editor's menu entries. This has to match
* the content in data/editor/world_menu.xml. An always-false if is
* used, because the strings are sourced from the XML. This only
* exists here to make xgettext(1) find them. */
#if 0
// TRANS: World editor left menu's entries follow
static std::string values[] = {_("---Sprites---"),
_("Way"),
_("Castle"),
_("Clouds"),
_("Hedges"),
_("Plants"),
_("Cactus"),
_("Hills"),
_("Mountains"),
_("Pipes"),
_("Lakes"),
_("Bridges"),
_("Blocks"),
_("Bones"),
_("Special"),
_("---Objects---"),
_("Generic"),
_("---Functions---"),
_("New"),
_("Load"),
_("Save")}

#endif

0 comments on commit 838c723

Please sign in to comment.
You can’t perform that action at this time.