Remove wstrgettext

Everywhere where wstrgettext was used, its output was converted back
to utf8. As wstrgettext internally converts the return value
from utf8 to wstring, it has been a waste. Remove the function, and
use strgettext instead.
master
est31 2015-10-18 02:29:06 +02:00
parent f3d82567c9
commit 6b0cae5a9d
3 changed files with 34 additions and 42 deletions

View File

@ -1048,7 +1048,7 @@ static void show_chat_menu(GUIFormSpecMenu **cur_formspec,
FORMSPEC_VERSION_STRING FORMSPEC_VERSION_STRING
SIZE_TAG SIZE_TAG
"field[3,2.35;6,0.5;f_text;;" + text + "]" "field[3,2.35;6,0.5;f_text;;" + text + "]"
"button_exit[4,3;3,0.5;btn_send;" + wide_to_utf8(wstrgettext("Proceed")) + "]" "button_exit[4,3;3,0.5;btn_send;" + strgettext("Proceed") + "]"
; ;
/* Create menu */ /* Create menu */
@ -1088,7 +1088,7 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
bool singleplayermode) bool singleplayermode)
{ {
#ifdef __ANDROID__ #ifdef __ANDROID__
std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n" std::string control_text = strgettext("Default Controls:\n"
"No menu visible:\n" "No menu visible:\n"
"- single tap: button activate\n" "- single tap: button activate\n"
"- double tap: place/use\n" "- double tap: place/use\n"
@ -1100,9 +1100,9 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
" --> move stack\n" " --> move stack\n"
"- touch&drag, tap 2nd finger\n" "- touch&drag, tap 2nd finger\n"
" --> place single item to slot\n" " --> place single item to slot\n"
)); );
#else #else
std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n" std::string control_text = strgettext("Default Controls:\n"
"- WASD: move\n" "- WASD: move\n"
"- Space: jump/climb\n" "- Space: jump/climb\n"
"- Shift: sneak/go down\n" "- Shift: sneak/go down\n"
@ -1113,7 +1113,7 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
"- Mouse right: place/use\n" "- Mouse right: place/use\n"
"- Mouse wheel: select item\n" "- Mouse wheel: select item\n"
"- T: chat\n" "- T: chat\n"
)); );
#endif #endif
float ypos = singleplayermode ? 0.5 : 0.1; float ypos = singleplayermode ? 0.5 : 0.1;
@ -1121,23 +1121,23 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
os << FORMSPEC_VERSION_STRING << SIZE_TAG os << FORMSPEC_VERSION_STRING << SIZE_TAG
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;" << "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
<< wide_to_utf8(wstrgettext("Continue")) << "]"; << strgettext("Continue") << "]";
if (!singleplayermode) { if (!singleplayermode) {
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;"
<< wide_to_utf8(wstrgettext("Change Password")) << "]"; << strgettext("Change Password") << "]";
} }
#ifndef __ANDROID__ #ifndef __ANDROID__
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
<< wide_to_utf8(wstrgettext("Sound Volume")) << "]"; << strgettext("Sound Volume") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
<< wide_to_utf8(wstrgettext("Change Keys")) << "]"; << strgettext("Change Keys") << "]";
#endif #endif
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
<< wide_to_utf8(wstrgettext("Exit to Menu")) << "]"; << strgettext("Exit to Menu") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
<< wide_to_utf8(wstrgettext("Exit to OS")) << "]" << strgettext("Exit to OS") << "]"
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]" << "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
<< "textarea[0.4,0.25;3.5,6;;" << PROJECT_NAME_C "\n" << "textarea[0.4,0.25;3.5,6;;" << PROJECT_NAME_C "\n"
<< g_build_info << "\n" << g_build_info << "\n"

View File

@ -48,14 +48,6 @@ inline const wchar_t *wgettext(const char *str)
return utf8_to_wide_c(gettext(str)); return utf8_to_wide_c(gettext(str));
} }
inline std::wstring wstrgettext(const std::string &text)
{
const wchar_t *tmp = wgettext(text.c_str());
std::wstring retval = (std::wstring)tmp;
delete[] tmp;
return retval;
}
inline std::string strgettext(const std::string &text) inline std::string strgettext(const std::string &text)
{ {
return gettext(text.c_str()); return gettext(text.c_str());

View File

@ -1059,8 +1059,8 @@ int ModApiMainMenu::l_get_video_modes(lua_State *L)
/******************************************************************************/ /******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L) int ModApiMainMenu::l_gettext(lua_State *L)
{ {
std::wstring wtext = wstrgettext((std::string) luaL_checkstring(L, 1)); std::string text = strgettext(std::string(luaL_checkstring(L, 1)));
lua_pushstring(L, wide_to_utf8(wtext).c_str()); lua_pushstring(L, text.c_str());
return 1; return 1;
} }