--- a/hedgewars/uScript.pas Sat Sep 12 19:00:52 2015 +0200
+++ b/hedgewars/uScript.pas Sat Sep 12 20:01:26 2015 +0200
@@ -90,6 +90,7 @@
uPhysFSLayer,
SDLh
{$IFNDEF PAS2C}
+ , uLocale
, typinfo
{$ENDIF}
;
@@ -2604,6 +2605,27 @@
lc_endluatest:= 0;
end;
+
+// localization
+function lc_loc(L: Plua_State) : LongInt; Cdecl;
+var si, so: shortstring;
+const
+ call = 'loc';
+ params = 'text';
+begin
+ if CheckLuaParamCount(L, 1, call, params) then
+ begin
+ si:= lua_tostring(L, 1);
+ {$IFNDEF PAS2C}
+ so:= locMOFile.Translate(si);
+ if Length(so) < 1 then
+ {$ENDIF}
+ so:= si;//'gettext("' + si + '")';
+ lua_pushstring(L, Str2PChar(so));
+ end;
+ lc_loc:= 1;
+end;
+
///////////////////
procedure ScriptPrintStack;
@@ -3334,6 +3356,8 @@
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload);
lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement);
+lua_register(luaState, _P'loc', @lc_loc);
+
ScriptSetInteger('TEST_SUCCESSFUL' , HaltTestSuccess);
ScriptSetInteger('TEST_FAILED' , HaltTestFailed);
lua_register(luaState, _P'EndLuaTest', @lc_endluatest);