diff options
author | LNJ <git@lnj.li> | 2017-04-11 13:02:31 +0200 |
---|---|---|
committer | LNJ <git@lnj.li> | 2017-04-11 13:02:31 +0200 |
commit | cde5c46e449e49e1435ac649bf344234ccd61f80 (patch) | |
tree | 57e4d51c44d4c4a052d948f0fb73217050a58285 /lua | |
parent | cb616b0df9e0a07b9e569898c1d3cc265e6c13bf (diff) |
Add i18n support using intllib
Diffstat (limited to 'lua')
-rwxr-xr-x | lua/api.lua | 12 | ||||
-rwxr-xr-x | lua/helpers.lua | 9 | ||||
-rwxr-xr-x | lua/visual.lua | 8 |
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) |