share/hedgewars/Data/Scripts/Locale.lua
author sheepluva
Sat, 12 Sep 2015 20:01:26 +0200
branchgettext
changeset 11168 e104e060911b
parent 8824 fe9eacd390f2
permissions -rw-r--r--
experimental gettext for lua
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4854
881c8232b66a adding my new Tracker library so mikade can use it with you guys on dev, still might change a bit though
Henek
parents: 4502
diff changeset
     1
-- Library for localizing strings in lua scripts
881c8232b66a adding my new Tracker library so mikade can use it with you guys on dev, still might change a bit though
Henek
parents: 4502
diff changeset
     2
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
     3
local lang = nil
4854
881c8232b66a adding my new Tracker library so mikade can use it with you guys on dev, still might change a bit though
Henek
parents: 4502
diff changeset
     4
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
     5
function lua_loc(text)
8824
fe9eacd390f2 Unbreak lua localisation, fix untranslated login prompt, update translations.
nemo
parents: 8349
diff changeset
     6
    if locale ~= nil and locale[text] ~= nil then return locale[text]
4502
759c1a3bb156 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.
Henek
parents:
diff changeset
     7
    else return text
759c1a3bb156 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.
Henek
parents:
diff changeset
     8
    end
759c1a3bb156 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.
Henek
parents:
diff changeset
     9
end
11168
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    10
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    11
if loc == nil then
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    12
    lang = HedgewarsScriptLoad("Locale/" .. tostring(L) .. ".lua")
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    13
    loc = lua_loc
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    14
end
e104e060911b experimental gettext for lua
sheepluva
parents: 8824
diff changeset
    15