project_files/Android-build/SDL-android-project/assets/Data/Scripts/Locale.lua
author Wuzzy <almikes@aol.com>
Mon, 02 Oct 2017 23:08:12 +0200
changeset 12641 00b55c1424d1
parent 7568 75ba91f14ed5
permissions -rw-r--r--
Update German translation (especially de.txt)
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