Fix maked strings of formspec escapes

master
Wuzzy 2014-10-02 10:08:39 +02:00
parent e559d9a270
commit 5f5f257ba4
3 changed files with 41 additions and 47 deletions

View File

@ -8,12 +8,8 @@ local S, F
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
F = function( s )
return minetest.formspec_escape(S(s))
end
else
S = function ( s ) return s end
F = function ( s ) return minetest.formspec_escape(s) end
end
WATER_ALPHA = 160
@ -28,7 +24,7 @@ default = {}
default.gui_bg = "bgcolor[#080808BB;true]"
default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]"
default.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
default.gui_controls = F("[left click]: take/drop stack; [right click]: take half / drop 1; [middle click]: take 10 / drop 10; [Esc] or [I]: Close")
default.gui_controls = minetest.formspec_escape(S("[left click]: take/drop stack; [right click]: take half / drop 1; [middle click]: take 10 / drop 10; [Esc] or [I]: Close"))
function default.get_hotbar_bg(x,y)
local out = ""
@ -42,14 +38,14 @@ default.gui_suvival_form = "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"button_exit[-0.1,-0.3;2,1;gotostart;"..F("Back to start").."]"..
"label[0,3.75;"..F("Player inventory:").."]"..
"button_exit[-0.1,-0.3;2,1;gotostart;"..minetest.formspec_escape(S("Back to start")).."]"..
"label[0,3.75;"..minetest.formspec_escape(S("Player inventory:")).."]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"label[0,8.2;"..default.gui_controls.."]"..
"label[2.75,-0.1;"..F("Crafting grid:").."]"..
"label[2.75,-0.1;"..minetest.formspec_escape(S("Crafting grid:")).."]"..
"list[current_player;craft;2.75,0.5;3,3;]"..
"label[6.75,0.9;"..F("Output slot:").."]"..
"label[6.75,0.9;"..minetest.formspec_escape(S("Output slot:")).."]"..
"list[current_player;craftpreview;6.75,1.5;1,1;]"..
"image[5.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
default.get_hotbar_bg(0,4.25)

View File

@ -256,9 +256,9 @@ default.chest_formspec =
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,-0.2;"..F("Chest inventory:").."]"..
"label[0,-0.2;"..minetest.formspec_escape(S("Chest inventory:")).."]"..
"list[current_name;main;0,0.3;8,4;]"..
"label[0,4.35;"..F("Player inventory:").."]"..
"label[0,4.35;"..minetest.formspec_escape(S("Player inventory:")).."]"..
"list[current_player;main;0,4.85;8,1;]"..
"list[current_player;main;0,6.08;8,3;8]"..
"label[0,8.8;"..default.gui_controls.."]"..
@ -305,20 +305,20 @@ function default.furnace_active(pos, percent, item_percent)
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[-0.1,-0.4;"..F("This furnace is active and constantly burning its fuel.").."]"..
"label[2.75,0;"..F("Source:").."]"..
"label[-0.1,-0.4;"..minetest.formspec_escape(S("This furnace is active and constantly burning its fuel.")).."]"..
"label[2.75,0;"..minetest.formspec_escape(S("Source:")).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
"label[2.75,2.4;"..F("Fuel:").."]"..
"label[2.75,2.4;"..minetest.formspec_escape(S("Fuel:")).."]"..
"list[current_name;fuel;2.75,2.9;1,1;]"..
"label[2.75,1.2;"..F("Flame:").."]"..
"label[2.75,1.2;"..minetest.formspec_escape(S("Flame:")).."]"..
"image[2.75,1.7;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-percent)..":default_furnace_fire_fg.png]"..
"label[3.75,1.2;"..F("Progress:").."]"..
"label[3.75,1.2;"..minetest.formspec_escape(S("Progress:")).."]"..
"image[3.75,1.7;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
(item_percent*100)..":gui_furnace_arrow_fg.png^[transformR270]"..
"label[4.75,0.66;"..F("Output slots:").."]"..
"label[4.75,0.66;"..minetest.formspec_escape(S("Output slots:")).."]"..
"list[current_name;dst;4.75,1.16;2,2;]"..
"label[0,3.75;"..F("Player inventory:").."]"..
"label[0,3.75;"..minetest.formspec_escape(S("Player inventory:")).."]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"label[0,8.2;"..default.gui_controls.."]"..
@ -347,18 +347,18 @@ default.furnace_inactive_formspec =
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[-0.1,-0.4;"..F("This furnace is inactive. Read the instructions to learn how to activate it.").."]"..
"label[2.75,0;"..F("Source:").."]"..
"label[-0.1,-0.4;"..minetest.formspec_escape(S("This furnace is inactive. Read the instructions to learn how to activate it.")).."]"..
"label[2.75,0;"..minetest.formspec_escape(S("Source:")).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
"label[2.75,2.4;"..F("Fuel:").."]"..
"label[2.75,2.4;"..minetest.formspec_escape(S("Fuel:")).."]"..
"list[current_name;fuel;2.75,2.9;1,1;]"..
"label[2.75,1.2;"..F("Flame:").."]"..
"label[2.75,1.2;"..minetest.formspec_escape(S("Flame:")).."]"..
"image[2.75,1.7;1,1;default_furnace_fire_bg.png]"..
"label[3.75,1.2;"..F("Progress:").."]"..
"label[3.75,1.2;"..minetest.formspec_escape(S("Progress:")).."]"..
"image[3.75,1.7;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"label[4.75,0.66;"..F("Output slots:").."]"..
"label[4.75,0.66;"..minetest.formspec_escape(S("Output slots:")).."]"..
"list[current_name;dst;4.75,1.16;2,2;]"..
"label[0,3.75;"..F("Player inventory:").."]"..
"label[0,3.75;"..minetest.formspec_escape(S("Player inventory:")).."]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"label[0,8.2;"..default.gui_controls.."]"..

View File

@ -4,10 +4,8 @@ tutorial = {}
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
F = minetest.formspec_escape(S(s))
else
S = function ( s ) return s end
F = function ( s ) return minetest.formspec_escape(s) end
end
-- Saves tutorial state into file
@ -81,13 +79,13 @@ function tutorial.register_infosign(itemstringpart, caption, fulltext)
local meta = minetest.get_meta(pos)
local formspec = ""..
"size[12,6]"..
"label[-0.15,-0.4;"..F(caption).."]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S(caption)).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;infosign_text;"..
tutorial.convert_newlines(F(fulltext))..
tutorial.convert_newlines(minetest.formspec_escape(S(fulltext)))..
"]"..
"button_exit[4.5,5.5;3,1;close;"..F("Close").."]"
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
meta:set_string("formspec", formspec)
meta:set_string("infotext", string.format(S("%s (Right-click to read)"), caption))
end
@ -986,7 +984,7 @@ function tutorial.show_default_dialog(name, caption, text)
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;text_table;"..
tutorial.convert_newlines(F(text))..
tutorial.convert_newlines(minetest.formspec_escape(S(text)))..
"]"..
"button_exit[4.5,5.5;3,1;close;Close]"
minetest.show_formspec(name, "tutorial_dialog", formspec)
@ -996,35 +994,35 @@ minetest.register_on_joinplayer(function(player)
local formspec = nil
if(minetest.is_singleplayer() == false) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..F("Warning: You're not playing in singleplayer mode").."]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Warning: You're not playing in singleplayer mode")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
tutorial.convert_newlines(F(tutorial.texts.notsingleplayer))..
tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.notsingleplayer)))..
"]"..
"button_exit[2.5,5.5;3,1;close;"..F("Continue anyways").."]"..
"button_exit[6.5,5.5;3,1;leave;"..F("Leave tutorial").."]"
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
elseif(minetest.setting_getbool("creative_mode")) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..(F("Warning: Creative mode is active")).."]"..
"label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
tutorial.convert_newlines(F(tutorial.texts.creative))..
tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.creative)))..
"]"..
"button_exit[2.5,5.5;3,1;close;"..F("Continue anyways").."]"..
"button_exit[6.5,5.5;3,1;leave;"..F("Leave tutorial").."]"
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
else
if(tutorial.state.first_join==true) then
formspec = "size[12,6]"..
"label[-0.15,-0.4;"..F("Introduction").."]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;intro_text;"..
tutorial.convert_newlines(F(tutorial.texts.intro))..
tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.intro)))..
"]"..
"button_exit[4.5,5.5;3,1;close;"..F("Close").."]"
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
end
tutorial.state.first_join = false
tutorial.save_state()
@ -1080,15 +1078,15 @@ minetest.register_globalstep(function(dtime)
local gold_stack = ItemStack("default:gold_ingot "..tostring(tutorial.gold))
if(inv:contains_item("main", gold_stack)) then
local formspec = "size[12,6]"..
"label[-0.15,-0.4;"..F("You've finished the tutorial!").."]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("You've finished the tutorial!")).."]"..
"tablecolumns[text]"..
"tableoptions[background=#000000;highlight=#000000;border=false]"..
"table[0,0.25;12,5.2;creative_text;"..
tutorial.convert_newlines(F(tutorial.texts.last_gold))..
tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.last_gold)))..
"]"..
"button_exit[0.5,5.5;3,1;close;"..F("Continue").."]"..
"button_exit[4.5,5.5;3,1;leave;"..F("Leave tutorial").."]"..
"button_exit[8.5,5.5;3,1;gotoend;"..F("Go to Good-Bye room").."]"
"button_exit[0.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
"button_exit[4.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"..
"button_exit[8.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
minetest.show_formspec(name, "tutorial_last_gold", formspec)