summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorLNJ <git@lnj.li>2017-04-11 13:02:31 +0200
committerLNJ <git@lnj.li>2017-04-11 13:02:31 +0200
commitcde5c46e449e49e1435ac649bf344234ccd61f80 (patch)
tree57e4d51c44d4c4a052d948f0fb73217050a58285 /lua
parentcb616b0df9e0a07b9e569898c1d3cc265e6c13bf (diff)
Add i18n support using intllib
Diffstat (limited to 'lua')
-rwxr-xr-xlua/api.lua12
-rwxr-xr-xlua/helpers.lua9
-rwxr-xr-xlua/visual.lua8
3 files changed, 20 insertions, 9 deletions
diff --git a/lua/api.lua b/lua/api.lua
index f49035b..9d54f53 100755
--- a/lua/api.lua
+++ b/lua/api.lua
@@ -25,6 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
+-- Load support for intllib.
+local MP = core.get_modpath(core.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
drawers.node_box_simple = {
{-0.5, -0.5, -0.4375, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, -0.4375, 0.5, -0.4375},
@@ -125,7 +129,7 @@ function drawers.drawer_insert_object(pos, node, stack, direction)
end
function drawers.register_drawer(name, def)
- def.description = def.description or "Wooden"
+ def.description = def.description or S("Wooden")
def.drawtype = "nodebox"
def.node_box = {type = "fixed", fixed = drawers.node_box_simple}
def.collision_box = {type = "regular"}
@@ -160,7 +164,7 @@ function drawers.register_drawer(name, def)
if drawers.enable_1x1 then
-- normal drawer 1x1 = 1
local def1 = table.copy(def)
- def1.description = def.description .. " Drawer"
+ def1.description = S("@1 Drawer", def.description)
def1.tiles = def.tiles or def.tiles1
def1.tiles1 = nil
def1.tiles2 = nil
@@ -173,7 +177,7 @@ function drawers.register_drawer(name, def)
if drawers.enable_1x2 then
-- 1x2 = 2
local def2 = table.copy(def)
- def2.description = def.description .. " Drawers (1x2)"
+ def2.description = S("@1 Drawers (1x2)", def.description)
def2.tiles = def.tiles2
def2.tiles1 = nil
def2.tiles2 = nil
@@ -185,7 +189,7 @@ function drawers.register_drawer(name, def)
if drawers.enable_2x2 then
-- 2x2 = 4
local def4 = table.copy(def)
- def4.description = def.description .. " Drawers (2x2)"
+ def4.description = S("@1 Drawers (2x2)", def.description)
def4.tiles = def.tiles4
def4.tiles1 = nil
def4.tiles2 = nil
diff --git a/lua/helpers.lua b/lua/helpers.lua
index 12997d1..fa1087a 100755
--- a/lua/helpers.lua
+++ b/lua/helpers.lua
@@ -25,6 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
+-- Load support for intllib.
+local MP = core.get_modpath(core.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
function drawers.gen_info_text(basename, count, factor, stack_max)
local maxCount = stack_max * factor
local percent = count / maxCount * 100
@@ -32,10 +36,9 @@ function drawers.gen_info_text(basename, count, factor, stack_max)
percent = math.floor(percent + 0.5)
if count == 0 then
- return basename .. " (" .. tostring(percent) .. "% full)"
+ return S("@1 (@2% full)", basename, tostring(percent))
else
- return tostring(count) .. " " .. basename .. " (" ..
- tostring(percent) .. "% full)"
+ return S("@1 @2 (@3% full)", tostring(count), basename, tostring(percent))
end
end
diff --git a/lua/visual.lua b/lua/visual.lua
index 178b15f..e0e99de 100755
--- a/lua/visual.lua
+++ b/lua/visual.lua
@@ -24,6 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
+-- Load support for intllib.
+local MP = core.get_modpath(core.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
core.register_entity("drawers:visual", {
initial_properties = {
hp_max = 1,
@@ -179,7 +183,7 @@ core.register_entity("drawers:visual", {
self.itemName = ""
meta:set_string("name"..self.visualId, self.itemName)
self.texture = "blank.png"
- itemDescription = "Empty"
+ itemDescription = S("Empty")
end
local infotext = drawers.gen_info_text(itemDescription,
@@ -243,7 +247,7 @@ core.register_entity("drawers:visual", {
if core.registered_items[self.itemName] then
itemDescription = core.registered_items[self.itemName].description
else
- itemDescription = "Empty"
+ itemDescription = S("Empty")
end
local infotext = drawers.gen_info_text(itemDescription,
self.count, self.stackMaxFactor, self.itemStackMax)