project_files/Android-build/SDL-android-project/assets/Data/Scripts/Locale.lua
author koda
Fri, 11 Oct 2013 17:43:13 +0200
branchwebgl
changeset 9521 8054d9d775fd
parent 7568 75ba91f14ed5
permissions -rw-r--r--
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7568
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     1
-- Library for localizing strings in lua scripts
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     2
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     3
local lang = loadfile(GetUserDataPath() .. "Locale/" .. tostring(L) .. ".lua")
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     4
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     5
if lang ~= nil then
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     6
    lang()
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     7
else
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     8
    lang = loadfile(GetDataPath() .. "Locale/" .. tostring(L) .. ".lua")
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     9
    if lang ~= nil then
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    10
        lang()
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    11
    end
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    12
end
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    13
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    14
function loc(text)
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    15
    if lang ~= nil and locale ~= nil and locale[text] ~= nil then return locale[text]
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    16
    else return text
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    17
    end
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    18
end