From 55eb230ef605660e307b1b7201f27e861adf6bec Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 12 Mar 2012 23:35:29 +0000 Subject: [PATCH] Add aegisub.gettext to get translations of strings Originally committed to SVN as r6583. --- aegisub/src/auto4_lua.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index c6badb177..5d6fac755 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -153,6 +153,13 @@ namespace { return 1; } + int get_translation(lua_State *L) + { + wxString str(check_wxstring(L, 1)); + lua_pushstring(L, _(str).utf8_str()); + return 1; + } + inline wxRegEx *get_regex(lua_State *L) { return static_cast(luaL_checkudata(L, 1, "aegisub.regex")); @@ -454,6 +461,7 @@ namespace Automation4 { set_field(L, "__init_regex", regex_init); set_field(L, "__init_clipboard", clipboard_init); set_field(L, "file_name", get_file_name); + set_field(L, "gettext", get_translation); // store aegisub table to globals lua_settable(L, LUA_GLOBALSINDEX);