Skip to content

Commit 6b0cae5

Browse files
committedOct 18, 2015
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.
1 parent f3d8256 commit 6b0cae5

File tree

3 files changed

+34
-42
lines changed

3 files changed

+34
-42
lines changed
 

‎src/game.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ static void show_chat_menu(GUIFormSpecMenu **cur_formspec,
10481048
FORMSPEC_VERSION_STRING
10491049
SIZE_TAG
10501050
"field[3,2.35;6,0.5;f_text;;" + text + "]"
1051-
"button_exit[4,3;3,0.5;btn_send;" + wide_to_utf8(wstrgettext("Proceed")) + "]"
1051+
"button_exit[4,3;3,0.5;btn_send;" + strgettext("Proceed") + "]"
10521052
;
10531053

10541054
/* Create menu */
@@ -1088,56 +1088,56 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
10881088
bool singleplayermode)
10891089
{
10901090
#ifdef __ANDROID__
1091-
std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n"
1092-
"No menu visible:\n"
1093-
"- single tap: button activate\n"
1094-
"- double tap: place/use\n"
1095-
"- slide finger: look around\n"
1096-
"Menu/Inventory visible:\n"
1097-
"- double tap (outside):\n"
1098-
" -->close\n"
1099-
"- touch stack, touch slot:\n"
1100-
" --> move stack\n"
1101-
"- touch&drag, tap 2nd finger\n"
1102-
" --> place single item to slot\n"
1103-
));
1091+
std::string control_text = strgettext("Default Controls:\n"
1092+
"No menu visible:\n"
1093+
"- single tap: button activate\n"
1094+
"- double tap: place/use\n"
1095+
"- slide finger: look around\n"
1096+
"Menu/Inventory visible:\n"
1097+
"- double tap (outside):\n"
1098+
" -->close\n"
1099+
"- touch stack, touch slot:\n"
1100+
" --> move stack\n"
1101+
"- touch&drag, tap 2nd finger\n"
1102+
" --> place single item to slot\n"
1103+
);
11041104
#else
1105-
std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n"
1106-
"- WASD: move\n"
1107-
"- Space: jump/climb\n"
1108-
"- Shift: sneak/go down\n"
1109-
"- Q: drop item\n"
1110-
"- I: inventory\n"
1111-
"- Mouse: turn/look\n"
1112-
"- Mouse left: dig/punch\n"
1113-
"- Mouse right: place/use\n"
1114-
"- Mouse wheel: select item\n"
1115-
"- T: chat\n"
1116-
));
1105+
std::string control_text = strgettext("Default Controls:\n"
1106+
"- WASD: move\n"
1107+
"- Space: jump/climb\n"
1108+
"- Shift: sneak/go down\n"
1109+
"- Q: drop item\n"
1110+
"- I: inventory\n"
1111+
"- Mouse: turn/look\n"
1112+
"- Mouse left: dig/punch\n"
1113+
"- Mouse right: place/use\n"
1114+
"- Mouse wheel: select item\n"
1115+
"- T: chat\n"
1116+
);
11171117
#endif
11181118

11191119
float ypos = singleplayermode ? 0.5 : 0.1;
11201120
std::ostringstream os;
11211121

11221122
os << FORMSPEC_VERSION_STRING << SIZE_TAG
11231123
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
1124-
<< wide_to_utf8(wstrgettext("Continue")) << "]";
1124+
<< strgettext("Continue") << "]";
11251125

11261126
if (!singleplayermode) {
11271127
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;"
1128-
<< wide_to_utf8(wstrgettext("Change Password")) << "]";
1128+
<< strgettext("Change Password") << "]";
11291129
}
11301130

11311131
#ifndef __ANDROID__
11321132
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
1133-
<< wide_to_utf8(wstrgettext("Sound Volume")) << "]";
1133+
<< strgettext("Sound Volume") << "]";
11341134
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
1135-
<< wide_to_utf8(wstrgettext("Change Keys")) << "]";
1135+
<< strgettext("Change Keys") << "]";
11361136
#endif
11371137
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
1138-
<< wide_to_utf8(wstrgettext("Exit to Menu")) << "]";
1138+
<< strgettext("Exit to Menu") << "]";
11391139
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
1140-
<< wide_to_utf8(wstrgettext("Exit to OS")) << "]"
1140+
<< strgettext("Exit to OS") << "]"
11411141
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
11421142
<< "textarea[0.4,0.25;3.5,6;;" << PROJECT_NAME_C "\n"
11431143
<< g_build_info << "\n"

‎src/gettext.h

-8
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ inline const wchar_t *wgettext(const char *str)
4848
return utf8_to_wide_c(gettext(str));
4949
}
5050

51-
inline std::wstring wstrgettext(const std::string &text)
52-
{
53-
const wchar_t *tmp = wgettext(text.c_str());
54-
std::wstring retval = (std::wstring)tmp;
55-
delete[] tmp;
56-
return retval;
57-
}
58-
5951
inline std::string strgettext(const std::string &text)
6052
{
6153
return gettext(text.c_str());

‎src/script/lua_api/l_mainmenu.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ int ModApiMainMenu::l_get_video_modes(lua_State *L)
10591059
/******************************************************************************/
10601060
int ModApiMainMenu::l_gettext(lua_State *L)
10611061
{
1062-
std::wstring wtext = wstrgettext((std::string) luaL_checkstring(L, 1));
1063-
lua_pushstring(L, wide_to_utf8(wtext).c_str());
1062+
std::string text = strgettext(std::string(luaL_checkstring(L, 1)));
1063+
lua_pushstring(L, text.c_str());
10641064

10651065
return 1;
10661066
}

0 commit comments

Comments
 (0)
Please sign in to comment.