intllib support, ported from not applied pull request to the new version

https://github.com/dmonty2/minetest-u_skinsdb/pull/1
This commit is contained in:
Alexander Weber 2016-09-05 19:20:16 +02:00
parent dd396bfad2
commit be8fa19b68
4 changed files with 36 additions and 9 deletions

View File

@ -1,3 +1,4 @@
unified_inventory
default
simple_skins?
simple_skins?
intllib?

View File

@ -2,6 +2,14 @@
-- Copyright (c) 2012 cornernote, Dean Montgomery
-- License: GPLv3
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if intllib then
S = intllib.Getter()
else
S = function(s) return s end
end
u_skins = {}
u_skins.modpath = minetest.get_modpath("u_skins")
u_skins.file = minetest.get_worldpath().."/u_skins.mt"
@ -62,29 +70,29 @@ unified_inventory.register_page("u_skins", {
local formspec = ("background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
.."image[0,.75;1,2;"..u_skins.u_skins[name].."_preview.png]"
.."label[6,.5;Raw texture:]"
.."label[6,.5;"..S("Raw texture")..":]"
.."image[6,1;2,1;"..u_skins.u_skins[name]..".png]")
local meta = u_skins.meta[u_skins.u_skins[name]]
if meta then
if meta.name ~= "" then
formspec = formspec.."label[2,.5;Name: "..minetest.formspec_escape(meta.name).."]"
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(meta.name).."]"
end
if meta.author ~= "" then
formspec = formspec.."label[2,1;Author: "..minetest.formspec_escape(meta.author).."]"
formspec = formspec.."label[2,1;"..S("Author")..": "..minetest.formspec_escape(meta.author).."]"
end
if meta.license ~= "" then
formspec = formspec.."label[2,1.5;License: "..minetest.formspec_escape(meta.license).."]"
formspec = formspec.."label[2,1.5;"..S("License")..": "..minetest.formspec_escape(meta.license).."]"
end
if meta.description ~= "" then --what's that??
formspec = formspec.."label[2,2;Description: "..minetest.formspec_escape(meta.description).."]"
formspec = formspec.."label[2,2;"..S("Description")..": "..minetest.formspec_escape(meta.description).."]"
end
end
local page = 0
if u_skins.pages[name] then
page = u_skins.pages[name]
end
formspec = formspec .. "button[.75,3;6.5,.5;u_skins_page$"..page..";Change]"
formspec = formspec .. "button[.75,3;6.5,.5;u_skins_page$"..page..";"..S("Change").."]"
return {formspec=formspec}
end,
})
@ -131,7 +139,7 @@ u_skins.generate_pages = function(texture)
end
formspec = (formspec
.."button[0,3.8;1,.5;u_skins_page$"..page_prev..";<<]"
.."button[.75,3.8;6.5,.5;u_skins_null;Page "..page.."/"..total_pages.."]"
.."button[.75,3.8;6.5,.5;u_skins_null;"..S("Page").." "..page.."/"..total_pages.."]"
.."button[7,3.8;1,.5;u_skins_page$"..page_next..";>>]")
unified_inventory.register_page("u_skins_page$"..(page - 1), {
@ -172,4 +180,4 @@ minetest.register_on_joinplayer(function(player)
end)
u_skins.generate_pages()
u_skins.load_players()
u_skins.load_players()

9
u_skins/locale/de.txt Normal file
View File

@ -0,0 +1,9 @@
# Translation by Xanthin
Raw texture = Rohtextur
Name = Name
Author = Autor
Change = Wechseln
Page = Seite
License = Lizenz
Description = Beschreibung

View File

@ -0,0 +1,9 @@
# Template
Raw texture =
Name =
Author =
Change =
Page =
License =
Description =