share/hedgewars/Data/Scripts/Locale.lua
author nemo
Sat, 17 Mar 2012 14:02:11 -0400
changeset 6788 88036f0e0a92
parent 5616 a96231121eac
child 8349 a1dbe148f10f
permissions -rw-r--r--
I think this is a little more efficient than dxdy, and easier to read. We call DxDy2 a lot, can any of those use Angle/DirAngle?

-- Library for localizing strings in lua scripts

local lang = loadfile(GetUserDataPath() .. "Locale/" .. tostring(L) .. ".lua")

if lang ~= nil then
    lang()
else
    lang = loadfile(GetDataPath() .. "Locale/" .. tostring(L) .. ".lua")
    if lang ~= nil then
        lang()
    end
end

function loc(text)
    if lang ~= nil and locale ~= nil and locale[text] ~= nil then return locale[text]
    else return text
    end
end