mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 01:10:22 +02:00
Add translation for main menu
Add engine.gettext() and remove gettext() calls in guiFormspecMenu.cpp
This commit is contained in:
@ -136,7 +136,6 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
|
||||
m_menu->lockSize(true,v2u32(800,600));
|
||||
m_menu->setFormSource(m_formspecgui);
|
||||
m_menu->setTextDest(m_buttonhandler);
|
||||
m_menu->useGettext(true);
|
||||
|
||||
// Initialize scripting
|
||||
|
||||
|
@ -44,10 +44,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "util/numeric.h"
|
||||
#include "filesys.h"
|
||||
#include "gettime.h"
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
|
||||
#define MY_CHECKPOS(a,b) \
|
||||
if (v_pos.size() != 2) { \
|
||||
errorstream<< "Invalid pos for element " << a << "specified: \"" \
|
||||
@ -88,7 +86,6 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
|
||||
m_listbox_doubleclick(false),
|
||||
m_tooltip_element(NULL),
|
||||
m_allowclose(true),
|
||||
m_use_gettext(false),
|
||||
m_lock(false)
|
||||
{
|
||||
current_keys_pending.key_down = false;
|
||||
@ -379,9 +376,6 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element) {
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext)
|
||||
wlabel = wstrgettext(label);
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
L"",
|
||||
@ -499,9 +493,6 @@ void GUIFormSpecMenu::parseButton(parserData* data,std::string element,std::stri
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext)
|
||||
wlabel = wstrgettext(label);
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
wlabel,
|
||||
@ -609,7 +600,6 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
|
||||
std::wstring toadd =
|
||||
narrow_to_wide(unescape_string(items[i]).c_str() + 7);
|
||||
|
||||
|
||||
e->addItem(toadd.c_str());
|
||||
|
||||
irr::video::SColor toset;
|
||||
@ -733,13 +723,6 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) {
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext) {
|
||||
if (label.length() > 1)
|
||||
wlabel = wstrgettext(label);
|
||||
else
|
||||
wlabel = L"";
|
||||
}
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
wlabel,
|
||||
@ -812,13 +795,6 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,std::vector<std::string>
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext) {
|
||||
if (label.length() > 1)
|
||||
wlabel = wstrgettext(label);
|
||||
else
|
||||
wlabel = L"";
|
||||
}
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
wlabel,
|
||||
@ -902,13 +878,6 @@ void GUIFormSpecMenu::parseTextArea(parserData* data,std::vector<std::string>& p
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext) {
|
||||
if (label.length() > 1)
|
||||
wlabel = wstrgettext(label);
|
||||
else
|
||||
wlabel = L"";
|
||||
}
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
wlabel,
|
||||
@ -989,9 +958,6 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element) {
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(text.c_str());
|
||||
|
||||
if (m_use_gettext)
|
||||
wlabel = wstrgettext(text);
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
L"",
|
||||
wlabel,
|
||||
@ -1026,12 +992,6 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element) {
|
||||
text = unescape_string(text);
|
||||
std::string label = "";
|
||||
|
||||
if (m_use_gettext) {
|
||||
const char* toset = gettext(text.c_str());
|
||||
|
||||
text = std::string(toset);
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i < text.length(); i++) {
|
||||
label += text.c_str()[i];
|
||||
label += "\n";
|
||||
@ -1098,9 +1058,6 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
|
||||
|
||||
std::wstring wlabel = narrow_to_wide(label.c_str());
|
||||
|
||||
if (m_use_gettext)
|
||||
wlabel = wstrgettext(label);
|
||||
|
||||
FieldSpec spec = FieldSpec(
|
||||
narrow_to_wide(name.c_str()),
|
||||
wlabel,
|
||||
@ -1194,15 +1151,9 @@ void GUIFormSpecMenu::parseTabHeader(parserData* data,std::string element) {
|
||||
for (unsigned int i=0; i< buttons.size(); i++) {
|
||||
wchar_t* wbutton = 0;
|
||||
|
||||
if (m_use_gettext)
|
||||
wbutton = wgettext(buttons[i].c_str());
|
||||
else
|
||||
wbutton = (wchar_t*) narrow_to_wide(buttons[i].c_str()).c_str();
|
||||
wbutton = (wchar_t*) narrow_to_wide(buttons[i].c_str()).c_str();
|
||||
|
||||
e->addTab(wbutton,-1);
|
||||
|
||||
if (m_use_gettext)
|
||||
delete[] wbutton;
|
||||
}
|
||||
|
||||
if ((tab_index >= 0) &&
|
||||
|
@ -206,10 +206,6 @@ public:
|
||||
m_allowclose = value;
|
||||
}
|
||||
|
||||
void useGettext(bool value) {
|
||||
m_use_gettext = true;
|
||||
}
|
||||
|
||||
void lockSize(bool lock,v2u32 basescreensize=v2u32(0,0)) {
|
||||
m_lock = lock;
|
||||
m_lockscreensize = basescreensize;
|
||||
@ -282,7 +278,6 @@ protected:
|
||||
gui::IGUIStaticText *m_tooltip_element;
|
||||
|
||||
bool m_allowclose;
|
||||
bool m_use_gettext;
|
||||
bool m_lock;
|
||||
v2u32 m_lockscreensize;
|
||||
private:
|
||||
|
@ -980,6 +980,16 @@ int ModApiMainMenu::l_download_file(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_gettext(lua_State *L)
|
||||
{
|
||||
const char* str = luaL_checkstring(L, 1);
|
||||
str = gettext(str);
|
||||
lua_pushstring(L, str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void ModApiMainMenu::Initialize(lua_State *L, int top)
|
||||
{
|
||||
@ -1013,4 +1023,5 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
||||
API_FCT(get_modstore_list);
|
||||
API_FCT(sound_play);
|
||||
API_FCT(sound_stop);
|
||||
API_FCT(gettext);
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ private:
|
||||
|
||||
static int l_sound_stop(lua_State *L);
|
||||
|
||||
static int l_gettext(lua_State *L);
|
||||
|
||||
//gui
|
||||
|
||||
static int l_show_keys_menu(lua_State *L);
|
||||
|
Reference in New Issue
Block a user