lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
authorHenek
Fri, 10 Dec 2010 23:58:15 +0100
changeset 4502 759c1a3bb156
parent 4501 53ac7d07e673
child 4503 a8ab151bcae3
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
hedgewars/uScript.pas
share/hedgewars/Data/CMakeLists.txt
share/hedgewars/Data/Locale/CMakeLists.txt
share/hedgewars/Data/Locale/de.lua
share/hedgewars/Data/Locale/es.lua
share/hedgewars/Data/Locale/pl.lua
share/hedgewars/Data/Locale/pt_BR.lua
share/hedgewars/Data/Locale/pt_PT.lua
share/hedgewars/Data/Locale/sk.lua
share/hedgewars/Data/Locale/sv.lua
share/hedgewars/Data/Maps/Basketball/map.lua
share/hedgewars/Data/Maps/Knockball/map.lua
share/hedgewars/Data/Scripts/CMakeLists.txt
share/hedgewars/Data/Scripts/Locale.lua
--- a/hedgewars/uScript.pas	Fri Dec 10 22:39:20 2010 +0100
+++ b/hedgewars/uScript.pas	Fri Dec 10 23:58:15 2010 +0100
@@ -1028,6 +1028,18 @@
         end;
     lc_setwind:= 0
 end;
+
+function lc_getdatapath(L : Plua_State) : LongInt; Cdecl;
+begin
+    if lua_gettop(L) <> 0 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetDataPath!');
+        lua_pushnil(L);
+        end
+    else
+        lua_pushstring(L, str2pchar(Pathz[ptData]));
+    lc_getdatapath:= 1
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -1082,7 +1094,6 @@
 end;
 
 procedure ScriptOnGameInit;
-var s, t : ansistring;
 begin
 // not required if there is no script to run
 if not ScriptLoaded then
@@ -1108,12 +1119,6 @@
 ScriptSetString('Map', '');
 ScriptSetString('Theme', '');
 
-// import locale
-s:= cLocaleFName;
-t:= '';
-SplitByChar(s, t, '.');
-ScriptSetString('L', s);
-
 ScriptCall('onGameInit');
 
 // pop game variables
@@ -1295,6 +1300,7 @@
     am : TAmmoType;
     st : TSound;
     he: THogEffect;
+    s, t : ansistring;
 begin
 // initialize lua
 luaState:= lua_open;
@@ -1310,6 +1316,12 @@
 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
 
+// import locale
+s:= cLocaleFName;
+t:= '';
+SplitByChar(s, t, '.');
+ScriptSetString('L', s);
+
 // import game flags
 ScriptSetInteger('gfForts', gfForts);
 ScriptSetInteger('gfMultiWeapon', gfMultiWeapon);
@@ -1434,6 +1446,7 @@
 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
 lua_register(luaState, 'GetRandom', @lc_getrandom);
 lua_register(luaState, 'SetWind', @lc_setwind);
+lua_register(luaState, 'GetDataPath', @lc_getdatapath);
 
 
 ScriptClearStack; // just to be sure stack is empty
--- a/share/hedgewars/Data/CMakeLists.txt	Fri Dec 10 22:39:20 2010 +0100
+++ b/share/hedgewars/Data/CMakeLists.txt	Fri Dec 10 23:58:15 2010 +0100
@@ -1,3 +1,3 @@
-foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Sounds" "Themes" "Missions" "Names" "misc")
+foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Sounds" "Themes" "Missions" "Names" "misc" "Scripts")
   add_subdirectory(${dir})
 endforeach(dir)
--- a/share/hedgewars/Data/Locale/CMakeLists.txt	Fri Dec 10 22:39:20 2010 +0100
+++ b/share/hedgewars/Data/Locale/CMakeLists.txt	Fri Dec 10 23:58:15 2010 +0100
@@ -1,6 +1,7 @@
 file(GLOB txttrans2 ??.txt)
 file(GLOB txttrans5 ?????.txt)
 file(GLOB tsfiles *.ts)
+file(GLOB luafiles *.lua)
 
 QT4_ADD_TRANSLATION(QM ${tsfiles})
 
@@ -13,6 +14,7 @@
 	${txttrans2}
 	${txttrans5}
 	${QM}
+	${luafiles}
 	DESTINATION ${SHAREPATH}Data/Locale
 )
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/de.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Basketball",
+	["Not So Friendly Match"] = "Kein-so-Freundschaftsspiel",
+	["Bat your opponents through the|baskets and out of the map!"] = "Schlage deine Widersacher durch|die Körbe und aus der Karte hinaus!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Schlage Bälle auf deine Widersacher|und lass sie ins Meer fallen!",
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s ist draußen und Team %d|erhält einen Punkt!| |Punktestand:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s ist draußen und Team %d|erhält eine Strafe!| |Punktestand:",
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/es.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Baloncesto",
+	["Not So Friendly Match"] = "Partido no-tan-amistoso",
+	["Bat your opponents through the|baskets and out of the map!"] = "¡Batea pelotas hacia tus enemigos|y hazlos caer al agua!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Schlage Bälle auf deine Widersacher|und lass sie ins Meer fallen!",
+	["%s is out and Team %d|scored a point!| |Score:"] = "¡%s cayó y Equipo %d|anotó un tanto!| |Puntuación:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "¡%s cayó y Equipo %d|anotó una falta!| |Puntuación:",
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/pl.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Koszykówka",
+	["Not So Friendly Match"] = "Mecz Nie-Do-Końca Towarzyski",
+	["Bat your opponents through the|baskets and out of the map!"] = "Uderzaj swoich przekiwników|wyrzucając przez kosz, poza mapę!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Uderzaj piłkami w swoich przeciwników|i strącaj ich do wody!",
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s utonął i drużyna %d|zdobyła punkt!| |Punktacja:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s utonął i drużyna %d|dostała punkt karny!| |Punktacja:",
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/pt_BR.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Basketball"
+	["Not So Friendly Match"] = "Partida não muito amigável"
+	["Bat your opponents through the|baskets and out of the map!"] = "Rebata seus oponentes para|fora do mapa através dos cestos!"
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Rebata as bolas em direção ao seus|e derrube-os no mar!"
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s está fora e a Equipe %d|marcou um ponto!| |Pontuação:"
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s está fora e a Equipe %d|sofreu uma penalidade!| |Pontuação:"
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/pt_PT.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Basketball",
+	["Not So Friendly Match"] = "Partida não muito amigável",
+	["Bat your opponents through the|baskets and out of the map!"] = "Bate os teus adversarios|fora do mapa acertando com eles no cesto!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Bate bolas contra os teus|enimigos e empurra-os ao mar!",
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s está fora e a equipa %d|soma um ponto!| |Pontuação:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s está fora e a equipa %d|perde um ponto!| |Pontuação:",
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/sk.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Basketbal",
+	["Not So Friendly Match"] = "Nie tak celkom priateľský zápas",
+	["Bat your opponents through the|baskets and out of the map!"] = "Odpálkujte vašich súperov do koša|a von z mapy!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Loptami triafajte vašich nepriateľov|a zhoďte ich tak do mora!",
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s je mimo hru a tím %d|získal bod!| |Skóre:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s je mimo hru a tím %d|dostal trestný bod!| |Skóre:",
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Locale/sv.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,9 @@
+locale = {
+	["Hedgewars-Basketball"] = "Hedgewars-Basket",
+	["Not So Friendly Match"] = "En inte så vänlig match",
+	["Bat your opponents through the|baskets and out of the map!"] = "Slå ner dina motståndare i|korgarna och ut ur kartan!",
+	["Hedgewars-Knockball"] = "Hedgewars-Knockball",
+	["Bat balls at your enemies and|push them into the sea!"] = "Slå bollar mot dina fiender|och slå ner dem i havet",
+	["%s is out and Team %d|scored a point!| |Score:"] = "%s är ute och lag %d|fick ett poäng!| |Poängställning:",
+	["%s is out and Team %d|scored a penalty!| |Score:"] = "%s är ute och lag %d|fick ett straff!| |Poängställning:",
+    }
--- a/share/hedgewars/Data/Maps/Basketball/map.lua	Fri Dec 10 22:39:20 2010 +0100
+++ b/share/hedgewars/Data/Maps/Basketball/map.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -1,100 +1,6 @@
--- Hedgewars - Basketball for 2+ Players
-
-local caption = {
-	["en"] = "Hedgewars-Basketball",
-	["de"] = "Hedgewars-Basketball",
-	["es"] = "Hedgewars-Baloncesto",
-	["pl"] = "Hedgewars-Koszykówka",
-	["pt_PT"] = "Hedgewars-Basketball",
-	["sk"] = "Hedgewars-Basketbal",
-	["sv"] = "Hedgewars-Basket",
-	["pt_BR"] = "Hedgewars-Basketball"
-	}
-
-local subcaption = {
-	["en"] = "Not So Friendly Match",
-	["de"] = "Kein-so-Freundschaftsspiel",
-	["es"] = "Partido no-tan-amistoso",
-	["pl"] = "Mecz Nie-Do-Końca Towarzyski",
-	["pt_PT"] = "Partida não muito amigável",
-	["sk"] = "Nie tak celkom priateľský zápas",
-	["sv"] = "En inte så vänlig match",
-	["pt_BR"] = "Partida não muito amigável"
-	}
-
-local goal = {
-	["en"] = "Bat your opponents through the|baskets and out of the map!",
-	["de"] = "Schlage deine Widersacher durch|die Körbe und aus der Karte hinaus!",
-	["es"] = "¡Batea a tus oponentes fuera del mapa a través de la canasta!",
-	["pl"] = "Uderzaj swoich przekiwników|wyrzucając przez kosz, poza mapę!",
-	["pt_PT"] = "Bate os teus adversarios|fora do mapa acertando com eles no cesto!",
-	["sk"] = "Odpálkujte vašich súperov do koša|a von z mapy!",
-	["sv"] = "Slå ner dina motståndare i|korgarna och ut ur kartan!",
-	["pt_BR"] = "Rebata seus oponentes para|fora do mapa através dos cestos!"
-	}
-
-local scored = {
-	["en"] = " scored a point!",
-	["de"] = " erhält einen Punkt!",
-	["es"] = " anotó un tanto!",
-	["pl"] = " zdobyła punkt!",
-	["pt_PT"] = " marca um cesto!",
-	["sk"] = " skóruje!",
-	["sv"] = " fick ett poäng",
-	["pt_BR"] = " fez uma cesta"
-	}
+loadfile(GetDataPath() .. "Scripts/Locale.lua")()
 
-local failed = {
-	["en"] = " scored a penalty!",
-	["de"] = " erhält eine Strafe!",
-	["es"] = " anotó una falta!",
-	["pl"] = " zdobyła punkt karny!",
-	["pt_PT"] = " perde um ponto!",
-	["sk"] = " dostáva trestný bod!",
-	["sv"] = " fick ett straff",
-	["pt_BR"] = " sofre uma penalidade"
-	}
-
-	local sscore = {
-	["en"] = "Score",
-	["de"] = "Punktestand",
-	["es"] = "Puntuación",
-	["pl"] = "Punktacja",
-	["pt_PT"] = "Pontuação",
-	["sk"] = "Skóre",
-	["sv"] = "Poängställning",
-	["pt_BR"] = "Pontuação"
-	}
-
-local team = {
-	["en"] = "Team",
-	["es"] = "Equipo",
-	["pl"] = "Drużyna",
-	["pt_PT"] = "Equipa",
-	["sk"] = "Tím",
-	["sv"] = "Lag",
-	["pt_BR"] = "Equipe"
-	}
-
-local drowning = {
-	["en"] = "is out and",
-	["de"] = "ist draußen und",
-	["es"] = "cayó y",
-	["pl"] = "jest wyautowany i",
-	["pt_PT"] = "está fora e",
-	["sk"] = "je mimo hru a",
-	["sv"] = "är ute och",
-	["pt_BR"] = "está fora e"
-	}
-
-local function loc(text)
-	if text == nil then return "**missing**"
-	elseif text[L] == nil then return text["en"]
-	else return text[L]
-	end
-end
-
----------------------------------------------------------------
+-- Hedgewars - Basketball for 2+ Players
 
 local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
 
@@ -111,7 +17,7 @@
 end
 
 function onGameStart()
-	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0)
+	ShowMission(loc("Hedgewars-Basketball"), loc("Not So Friendly Match"), loc("Bat your opponents through the|baskets and out of the map!"), -amBaseballBat, 0)
 	started = true
 end
 
@@ -132,16 +38,18 @@
 	end
 	if (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then
 		local clan = GetHogClan(CurrentHedgehog)
-		local s = GetHogName(gear) .. " " .. loc(drowning) .. "|" .. loc(team) .. " " .. (clan + 1) .. " "
-		if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
-			score[clan] = score[clan] + 1
-			s = s .. loc(scored)
-		else
-			score[clan] = score[clan] - 1
-			s = s .. loc(failed)
+		local s
+		if clan ~= nil then
+			if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
+				score[clan] = score[clan] + 1
+				s = string.format(loc("%s is out and Team %d|scored a point!| |Score:"), GetHogName(gear), clan + 1)
+			else
+				score[clan] = score[clan] - 1
+				s = string.format(loc("%s is out and Team %d|scored a penalty!| |Score:"), GetHogName(gear), clan + 1)
+			end
+			s = s .. " " .. score[0]
+			for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
+			ShowMission(loc("Hedgewars-Basketball"), loc("Not So Friendly Match"), s, -amBaseballBat, 0)
 		end
-		s = s .. "| |" .. loc(sscore) .. ": " .. score[0]
-		for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
-		ShowMission(loc(caption), loc(subcaption), s, -amBaseballBat, 0)
 	end
 end
--- a/share/hedgewars/Data/Maps/Knockball/map.lua	Fri Dec 10 22:39:20 2010 +0100
+++ b/share/hedgewars/Data/Maps/Knockball/map.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -1,68 +1,6 @@
--- Hedgewars - Knockball for 2+ Players
-
-local caption = {
-	["en"] = "Hedgewars-Knockball",
-	["de"] = "Hedgewars-Knockball",
-	["es"] = "Hedgewars-Knockball",
-	["pl"] = "Hedgewars-Knockball",
-	["pt_PT"] = "Hedgewars-Knockball",
-	["sk"] = "Hedgewars-Knockball",
-	["sv"] = "Hedgewars-Knockball",
-	["pt_BR"] = "Hedgewars-Knockball"
-	}
-
-local subcaption = {
-	["en"] = "Not So Friendly Match",
-	["de"] = "Kein-so-Freundschaftsspiel",
-	["es"] = "Partido no-tan-amistoso",
-	["pl"] = "Mecz Nie-Do-Końca Towarzyski",
-	["pt_PT"] = "Partida não muito amigável",
-	["sk"] = "Nie tak celkom priateľský zápas",
-	["sv"] = "En inte så vänlig match",
-	["pt_BR"] = "Partida não muito amigável"
-	}
+loadfile(GetDataPath() .. "Scripts/Locale.lua")()
 
-local goal = {
-	["en"] = "Bat balls at your enemies and|push them into the sea!",
-	["de"] = "Schlage Bälle auf deine Widersacher|und lass sie ins Meer fallen!",
-	["es"] = "¡Batea pelotas hacia tus enemigos|y hazlos caer al agua!",
-	["pl"] = "Uderzaj piłkami w swoich przeciwników|i strącaj ich do wody!",
-	["pt_PT"] = "Bate bolas contra os teus|enimigos e empurra-os ao mar!",
-	["sk"] = "Loptami triafajte vašich nepriateľov|a zhoďte ich tak do mora!",
-	["sv"] = "Slå bollar mot dina fiender|och slå ner dem i havet",
-	["pt_BR"] = "Rebata as bolas em direção ao seus|e derrube-os no mar!"
-	}
-
-local scored = {
-	["en"] = "%s is out and Team %d|scored a point!| |Score:",
-	["de"] = "%s ist draußen und Team %d|erhält einen Punkt!| |Punktestand:",
-	["es"] = "¡%s cayó y Equipo %d|anotó un tanto!| |Puntuación:",
-	["pl"] = "%s utonął i drużyna %d|zdobyła punkt!| |Punktacja:",
-	["pt_PT"] = "%s está fora e a equipa %d|soma um ponto!| |Pontuação:",
-	["sk"] = "%s je mimo hru a tím %d|získal bod!| |Skóre:",
-	["sv"] = "%s är ute och lag %d|fick ett poäng!| |Poängställning:",
-	["pt_BR"] = "%s está fora e a Equipe %d|marcou um ponto!| |Pontuação:"
-	}
-
-local failed = {
-	["en"] = "%s is out and Team %d|scored a penalty!| |Score:",
-	["de"] = "%s ist draußen und Team %d|erhält eine Strafe!| |Punktestand:",
-	["es"] = "¡%s cayó y Equipo %d|anotó una falta!| |Puntuación:",
-	["pl"] = "%s utonął i drużyna %d|dostała punkt karny!| |Punktacja:",
-	["pt_PT"] = "%s está fora e a equipa %d|perde um ponto!| |Pontuação:",
-	["sk"] = "%s je mimo hru a tím %d|dostal trestný bod!| |Skóre:",
-	["sv"] = "%s är ute och lag %d|fick ett straff!| |Poängställning:",
-	["pt_BR"] = "%s está fora e a Equipe %d|sofreu uma penalidade!| |Pontuação:"
-	}
-
-local function loc(text)
-	if text == nil then return "**missing**"
-	elseif text[L] == nil then return text["en"]
-	else return text[L]
-	end
-end
-
----------------------------------------------------------------
+-- Hedgewars - Knockball for 2+ Players
 
 local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
 
@@ -81,7 +19,7 @@
 end
 
 function onGameStart()
-	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0)
+	ShowMission(loc("Hedgewars-Knockball"), loc("Not So Friendly Match"), loc("Bat balls at your enemies and|push them into the sea!"), -amBaseballBat, 0)
 	started = true
 end
 
@@ -118,14 +56,14 @@
 		if clan ~= nil then
 			if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
 				score[clan] = score[clan] + 1
-				s = string.format(loc(scored), GetHogName(gear), clan + 1)
+				s = string.format(loc("%s is out and Team %d|scored a point!| |Score:"), GetHogName(gear), clan + 1)
 			else
 				score[clan] = score[clan] - 1
-				s = string.format(loc(failed), GetHogName(gear), clan + 1)
+				s = string.format(loc("%s is out and Team %d|scored a penalty!| |Score:"), GetHogName(gear), clan + 1)
 			end
 			s = s .. " " .. score[0]
 			for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
-			ShowMission(loc(caption), loc(subcaption), s, -amBaseballBat, 0)
+			ShowMission(loc("Hedgewars-Knockball"), loc("Not So Friendly Match"), s, -amBaseballBat, 0)
 		end
 	end
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/CMakeLists.txt	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,6 @@
+file(GLOB luafiles *.lua)
+
+install(FILES
+	${luafiles}
+	DESTINATION ${SHAREPATH}Data/Scripts)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/Locale.lua	Fri Dec 10 23:58:15 2010 +0100
@@ -0,0 +1,10 @@
+local lang = loadfile(GetDataPath() .. "Locale/" .. tostring(L) .. ".lua")
+if lang ~= nil then
+    lang()
+end
+
+function loc(text)
+    if lang ~= nil and locale ~= nil and locale[text] ~= nil then return locale[text]
+    else return text
+    end
+end