diff options
| author | xisd <zlexis.dnl@googlemail.com> | 2016-10-18 18:13:59 +0200 | 
|---|---|---|
| committer | Auke Kok <sofar+github@foo-projects.org> | 2016-10-18 09:13:59 -0700 | 
| commit | e6421d8d495c4415eeae80c7b1a2ce20d55e443d (patch) | |
| tree | 1f2c38e7e72f7bd5dbd04888d7bc758d007326af | |
| parent | 65729b9d33fde507a4044b25cd29fba2d8a5eb50 (diff) | |
Intllib (#5)
Support for translation via intllib.
| -rw-r--r-- | cooking.lua | 11 | ||||
| -rw-r--r-- | corn.lua | 30 | ||||
| -rw-r--r-- | depends.txt | 1 | ||||
| -rw-r--r-- | init.lua | 18 | ||||
| -rw-r--r-- | locale/template.txt | 40 | ||||
| -rw-r--r-- | melon.lua | 13 | ||||
| -rw-r--r-- | polebean.lua | 17 | ||||
| -rw-r--r-- | potato.lua | 11 | ||||
| -rw-r--r-- | pumpkin.lua | 13 | ||||
| -rw-r--r-- | tomato.lua | 14 | ||||
| -rw-r--r-- | tools.lua | 8 | 
11 files changed, 125 insertions, 51 deletions
diff --git a/cooking.lua b/cooking.lua index e9859b0..1d58bf2 100644 --- a/cooking.lua +++ b/cooking.lua @@ -16,8 +16,11 @@ of the license, or (at your option) any later version.  -- ways or use other items  -- +-- Intllib +local S = crops.intllib +  minetest.register_craftitem("crops:unbaked_clay_bowl", { -	description = "Unbaked clay bowl", +	description = S("Unbaked clay bowl"),  	inventory_image = "crops_unbaked_clay_bowl.png",  }) @@ -31,7 +34,7 @@ minetest.register_craft({  })  minetest.register_craftitem("crops:clay_bowl", { -	description = "Clay bowl", +	description = S("Clay bowl"),  	inventory_image = "crops_clay_bowl.png",  	groups = { food_bowl=1 }  }) @@ -43,7 +46,7 @@ minetest.register_craft({  })  minetest.register_craftitem("crops:vegetable_stew", { -	description = "Bowl of vegetable stew", +	description = S("Bowl of vegetable stew"),  	inventory_image = "crops_bowl_vegetable_stew.png",  	groups = { eatable=1 },  	on_use = minetest.item_eat(8, "crops:clay_bowl"), @@ -56,7 +59,7 @@ minetest.register_craft({  })  minetest.register_craftitem("crops:uncooked_vegetable_stew", { -	description = "Bowl of uncooked vegetable stew", +	description = S("Bowl of uncooked vegetable stew"),  	inventory_image = "crops_bowl_uncooked_vegetable_stew.png",  	groups = { eatable=1 },  	on_use = minetest.item_eat(2, "crops:clay_bowl") @@ -10,8 +10,11 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  minetest.register_node("crops:corn", { -	description = "corn", +	description = S("Corn"),  	inventory_image = "crops_corn.png",  	wield_image = "crops_corn.png",  	tiles = { "crops_corn_base_seed.png" }, @@ -42,7 +45,7 @@ minetest.register_node("crops:corn", {  })  minetest.register_craftitem("crops:corn_cob", { -	description = "Corn Cob", +	description = S("Corn Cob"),  	inventory_image = "crops_corn_cob.png",  }) @@ -53,7 +56,7 @@ minetest.register_craft({  })  minetest.register_craftitem("crops:corn_on_the_cob", { -	description = "Corn on the Cob", +	description = S("Corn on the Cob"),  	inventory_image = "crops_corn_on_the_cob.png",  	on_use = minetest.item_eat(1)  }) @@ -66,7 +69,7 @@ minetest.register_craft({  minetest.register_node("crops:corn_base_seed", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	waving = 1,  	mesh = "crops_orthogonal_plant.obj", @@ -81,7 +84,7 @@ minetest.register_node("crops:corn_base_seed", {  	selection_box = {  		type = "fixed",  		fixed = {-0.5, -0.5, -0.5,  0.5, -0.3, 0.5} -	}, +	}  })  minetest.register_abm({ @@ -99,7 +102,7 @@ minetest.register_abm({  minetest.register_node("crops:corn_base_1", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_base_1.png" }, @@ -137,7 +140,7 @@ minetest.register_abm({  minetest.register_node("crops:corn_base_2", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_base_2.png" }, @@ -176,7 +179,7 @@ minetest.register_node("crops:corn_base_2", {  minetest.register_node("crops:corn_base_3", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_base_3.png" }, @@ -198,7 +201,7 @@ minetest.register_node("crops:corn_base_3", {  minetest.register_node("crops:corn_top_1", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_base_1.png" }, @@ -235,7 +238,7 @@ minetest.register_abm({  minetest.register_node("crops:corn_top_2", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_top_1.png" }, @@ -247,6 +250,7 @@ minetest.register_node("crops:corn_top_2", {  	groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), +	  	on_dig = function(pos, node, digger)  		local below = {x = pos.x, y = pos.y - 1, z = pos.z}  		if not minetest.get_node(below).name == "crops:base_2" then @@ -274,7 +278,7 @@ minetest.register_abm({  minetest.register_node("crops:corn_top_3", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_top_2.png" }, @@ -286,6 +290,7 @@ minetest.register_node("crops:corn_top_3", {  	groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), +	  	on_dig = function(pos, node, digger)  		local below = { x = pos.x, y = pos.y - 1, z = pos.z }  		local meta = minetest.get_meta(below) @@ -304,7 +309,7 @@ minetest.register_node("crops:corn_top_3", {  minetest.register_node("crops:corn_top_4", {  	visual = "mesh", -	description = "corn plant", +	description = S("Corn plant"),  	drawtype = "mesh",  	mesh = "crops_orthogonal_plant.obj",  	tiles = { "crops_corn_top_3.png" }, @@ -316,6 +321,7 @@ minetest.register_node("crops:corn_top_4", {  	groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), +	  	on_dig = function(pos, node, digger)  		local below = {x = pos.x, y = pos.y - 1, z = pos.z}  		if minetest.get_node(below).name == "crops:corn_base_3" then diff --git a/depends.txt b/depends.txt index d77ba25..657056a 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@  default  farming +intllib? @@ -58,6 +58,16 @@ settings.difficult = {  	hydration = true,  } + +-- Intllib +local S +if minetest.get_modpath("intllib") then +	S = intllib.Getter() +else +	S = function(s) return s end +end +crops.intllib = S +  local worldpath = minetest.get_worldpath()  local modpath = minetest.get_modpath(minetest.get_current_modname()) @@ -82,15 +92,15 @@ end  if not crops.difficulty then  	crops.difficulty = "normal" -	minetest.log("error", "Defaulting to \"normal\" difficulty settings") +	minetest.log("error", S("Defaulting to \"normal\" difficulty settings"))  end  crops.settings = settings[crops.difficulty]  if not crops.settings then -	minetest.log("error", "Defaulting to \"normal\" difficulty settings") +	minetest.log("error", S("Defaulting to \"normal\" difficulty settings"))  	crops.settings = settings.normal  end  if crops.settings.hydration then -	minetest.log("action", "[crops] Hydration and dehydration mechanics are enabled.") +	minetest.log("action", S("[crops] Hydration and dehydration mechanics are enabled."))  end  local find_plant = function(node) @@ -99,7 +109,7 @@ local find_plant = function(node)  			return crops.plants[i]  		end  	end -	minetest.log("error", "Unable to find plant \"" .. node.name .. "\" in crops table") +	minetest.log("error", S("Unable to find plant").." \"".. node.name .. "\" "..S("in crops table"))  	return nil  end diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..bf92432 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,40 @@ +Defaulting to \"normal\" difficulty settings =  +[crops] Hydration and dehydration mechanics are enabled. =  +Unable to find plant =  +in crops table =  +Unbaked clay bowl =  +Clay bowl =  +Bowl of vegetable stew =  +Bowl of uncooked vegetable stew =  + +Corn =  +Corn Cob =  +Corn on the Cob =  +Corn plant =  + +Melon seed =  +Melon plant =  +Melon slice =  +Melon =  + +Beanpole =  +Green Bean =  +Green bean seed =  +Green Bean plant =  + +Potato eyes =  +Potato plant =  +Potato =  +Soil with potatoes =  +  +Pumpkin seed =  +Pumpkin plant =  +Roasted pumpkin =  +Pumpkin =  +  +Tomato seed =  +Tomato plant =  +Tomato =  + +Watering Can =  +Hydrometer =  @@ -10,6 +10,9 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  local faces = {  	[1] = { x = -1, z = 0, r = 3, o = 1, m = 14 },  	[2] = { x = 1, z = 0, r = 1, o = 3,  m = 16 }, @@ -18,7 +21,7 @@ local faces = {  }  minetest.register_node("crops:melon_seed", { -	description = "melon seed", +	description = S("Melon seed"),  	inventory_image = "crops_melon_seed.png",  	wield_image = "crops_melon_seed.png",  	tiles = { "crops_melon_plant_1.png" }, @@ -46,7 +49,7 @@ minetest.register_node("crops:melon_seed", {  for stage = 1, 6 do  minetest.register_node("crops:melon_plant_" .. stage , { -	description = "melon plant", +	description = S("Melon plant"),  	tiles = { "crops_melon_plant_" .. stage .. ".png" },  	drawtype = "plantlike",  	waving = 1, @@ -67,7 +70,7 @@ end  minetest.register_node("crops:melon_plant_5_attached", {  	visual = "mesh",  	mesh = "crops_plant_extra_face.obj", -	description = "melon plant", +	description = S("Melon plant"),  	tiles = { "crops_melon_stem.png", "crops_melon_plant_4.png" },  	drawtype = "mesh",  	paramtype2 = "facedir", @@ -82,7 +85,7 @@ minetest.register_node("crops:melon_plant_5_attached", {  minetest.register_craftitem("crops:melon_slice", { -	description = "Melon slice", +	description = S("Melon slice"),  	inventory_image = "crops_melon_slice.png",  	on_use = minetest.item_eat(1)  }) @@ -97,7 +100,7 @@ minetest.register_craft({  -- the melon "block"  --  minetest.register_node("crops:melon", { -	description = "Melon", +	description = S("Melon"),  	tiles = { "crops_melon_top.png", "crops_melon_bottom.png", "crops_melon.png", "crops_melon.png", "crops_melon.png", "crops_melon.png" },  	sunlight_propagates = false,  	use_texture_alpha = false, diff --git a/polebean.lua b/polebean.lua index a729288..6af7cff 100644 --- a/polebean.lua +++ b/polebean.lua @@ -10,6 +10,9 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  minetest.register_craft({  	output = "crops:beanpoles",  	recipe = { @@ -20,7 +23,7 @@ minetest.register_craft({  })  minetest.register_craftitem("crops:green_bean", { -	description = "Green Bean", +	description = S("Green Bean"),  	inventory_image = "crops_green_bean.png",  	on_use = minetest.item_eat(1)  }) @@ -127,7 +130,6 @@ minetest.register_node("crops:beanpole_base", {  	groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), -  	on_dig = crops_beanpole_on_dig,  }) @@ -142,12 +144,11 @@ minetest.register_node("crops:beanpole_top", {  	groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), -  	on_dig = crops_beanpole_on_dig,  })  minetest.register_node("crops:beanpoles", { -	description = "beanpoles", +	description = "S(Beanpoles)",  	inventory_image = "crops_beanpole_top.png",  	wield_image = "crops_beanpole_top.png",  	tiles = { "crops_beanpole_base.png" }, @@ -179,7 +180,7 @@ minetest.register_node("crops:beanpoles", {  })  minetest.register_craftitem("crops:green_bean_seed", { -	description = "green bean seed", +	description = S("Green bean seed"),  	inventory_image = "crops_green_bean_seed.png",  	wield_image = "crops_green_bean_seed.png",  	node_placement_prediction = "", -- disabled, prediction assumes pointed_think.above! @@ -212,7 +213,7 @@ minetest.register_craftitem("crops:green_bean_seed", {  for stage = 1,6 do  minetest.register_node("crops:beanpole_plant_base_" .. stage, { -	description = "green bean plant", +	description = S("Green Bean plant"),  	tiles = { "crops_beanpole_plant_base_" .. stage .. ".png" },  	drawtype = "plantlike",  	sunlight_propagates = true, @@ -222,14 +223,13 @@ minetest.register_node("crops:beanpole_plant_base_" .. stage, {  	groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), -  	on_dig = crops_beanpole_on_dig  })  end  for stage = 1,4 do  minetest.register_node("crops:beanpole_plant_top_" .. stage, { -	description = "green bean plant", +	description = S("green bean plant"),  	tiles = { "crops_beanpole_plant_top_" .. stage .. ".png" },  	drawtype = "plantlike",  	sunlight_propagates = true, @@ -239,7 +239,6 @@ minetest.register_node("crops:beanpole_plant_top_" .. stage, {  	groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },  	drop = {},  	sounds = default.node_sound_leaves_defaults(), -  	on_dig = crops_beanpole_on_dig  })  end @@ -10,8 +10,11 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  minetest.register_node("crops:potato_eyes", { -	description = "potato eyes", +	description = S("Potato eyes"),  	inventory_image = "crops_potato_eyes.png",  	wield_image = "crops_potato_eyes.png",  	tiles = { "crops_potato_plant_1.png" }, @@ -43,7 +46,7 @@ minetest.register_node("crops:potato_eyes", {  for stage = 1, 5 do  minetest.register_node("crops:potato_plant_" .. stage , { -	description = "potato plant", +	description = S("Potato plant"),  	tiles = { "crops_potato_plant_" .. stage .. ".png" },  	drawtype = "plantlike",  	waving = 1, @@ -62,7 +65,7 @@ minetest.register_node("crops:potato_plant_" .. stage , {  end  minetest.register_craftitem("crops:potato", { -	description = "potato", +	description = S("Potato"),  	inventory_image = "crops_potato.png",  	on_use = minetest.item_eat(1)  }) @@ -77,7 +80,7 @@ minetest.register_craft({  -- the potatoes "block"  --  minetest.register_node("crops:soil_with_potatoes", { -	description = "Soil with potatoes", +	description = S("Soil with potatoes"),  	tiles = { "default_dirt.png^crops_potato_soil.png", "default_dirt.png" },  	sunlight_propagates = false,  	use_texture_alpha = false, diff --git a/pumpkin.lua b/pumpkin.lua index 32d3d31..bf08374 100644 --- a/pumpkin.lua +++ b/pumpkin.lua @@ -10,6 +10,9 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  local faces = {  	[1] = { x = -1, z = 0, r = 3, o = 1, m = 14 },  	[2] = { x = 1, z = 0, r = 1, o = 3,  m = 16 }, @@ -18,7 +21,7 @@ local faces = {  }  minetest.register_node("crops:pumpkin_seed", { -	description = "pumpkin seed", +	description = S("Pumpkin seed"),  	inventory_image = "crops_pumpkin_seed.png",  	wield_image = "crops_pumpkin_seed.png",  	tiles = { "crops_pumpkin_plant_1.png" }, @@ -46,7 +49,7 @@ minetest.register_node("crops:pumpkin_seed", {  for stage = 1, 6 do  minetest.register_node("crops:pumpkin_plant_" .. stage , { -	description = "pumpkin plant", +	description = S("Pumpkin plant"),  	tiles = { "crops_pumpkin_plant_" .. stage .. ".png" },  	drawtype = "plantlike",  	waving = 1, @@ -67,7 +70,7 @@ end  minetest.register_node("crops:pumpkin_plant_5_attached", {  	visual = "mesh",  	mesh = "crops_plant_extra_face.obj", -	description = "pumpkin plant", +	description = S("Pumpkin plant"),  	tiles = { "crops_pumpkin_stem.png", "crops_pumpkin_plant_4.png" },  	drawtype = "mesh",  	paramtype2 = "facedir", @@ -82,7 +85,7 @@ minetest.register_node("crops:pumpkin_plant_5_attached", {  minetest.register_craftitem("crops:roasted_pumpkin", { -	description = "Roasted pumpkin", +	description = S("Roasted pumpkin"),  	inventory_image = "crops_roasted_pumpkin.png",  	on_use = minetest.item_eat(2)  }) @@ -103,7 +106,7 @@ minetest.register_craft({  -- the pumpkin "block"  --  minetest.register_node("crops:pumpkin", { -	description = "Pumpkin", +	description = S("Pumpkin"),  	tiles = { "crops_pumpkin_top.png", "crops_pumpkin_bottom.png", "crops_pumpkin.png", "crops_pumpkin.png", "crops_pumpkin.png", "crops_pumpkin.png" },  	sunlight_propagates = false,  	use_texture_alpha = false, @@ -10,10 +10,13 @@ of the license, or (at your option) any later version.  --]] +-- Intllib +local S = crops.intllib +  local wateruse = 1  minetest.register_node("crops:tomato_seed", { -	description = "tomato seed", +	description = S("Tomato seed"),  	inventory_image = "crops_tomato_seed.png",  	wield_image = "crops_tomato_seed.png",  	tiles = { "crops_tomato_plant_1.png" }, @@ -43,7 +46,7 @@ minetest.register_node("crops:tomato_seed", {  for stage = 1, 4 do  minetest.register_node("crops:tomato_plant_" .. stage , { -	description = "tomato plant", +	description = S("Tomato plant"),  	tiles = { "crops_tomato_plant_" .. stage .. ".png" },  	drawtype = "plantlike",  	waving = 1, @@ -62,7 +65,7 @@ minetest.register_node("crops:tomato_plant_" .. stage , {  end  minetest.register_node("crops:tomato_plant_5" , { -	description = "tomato plant", +	description = S("Tomato plant"),  	tiles = { "crops_tomato_plant_5.png" },  	drawtype = "plantlike",  	waving = 1, @@ -96,7 +99,7 @@ minetest.register_node("crops:tomato_plant_5" , {  })  minetest.register_node("crops:tomato_plant_6", { -	description = "tomato plant", +	description = S("Tomato plant"),  	tiles = { "crops_tomato_plant_6.png" },  	drawtype = "plantlike",  	waving = 1, @@ -114,7 +117,7 @@ minetest.register_node("crops:tomato_plant_6", {  })  minetest.register_craftitem("crops:tomato", { -	description = "Tomato", +	description = S("Tomato"),  	inventory_image = "crops_tomato.png",  	on_use = minetest.item_eat(1)  }) @@ -194,4 +197,3 @@ crops.register({ name = "crops:tomato_plant_2", properties = properties })  crops.register({ name = "crops:tomato_plant_3", properties = properties })  crops.register({ name = "crops:tomato_plant_4", properties = properties })  crops.register({ name = "crops:tomato_plant_5", properties = properties }) - @@ -8,8 +8,12 @@ published by the Free Software Foundation; either version 2.1  of the license, or (at your option) any later version.  --]] + +-- Intllib +local S = crops.intllib +  minetest.register_tool("crops:watering_can", { -	description = "Watering Can", +	description = S("Watering Can"),  	inventory_image = "crops_watering_can.png",  	liquids_pointable = true,  	range = 2.5, @@ -73,7 +77,7 @@ minetest.register_tool("crops:watering_can", {  })  minetest.register_tool("crops:hydrometer", { -	description = "Hydrometer", +	description = S("Hydrometer"),  	inventory_image = "crops_hydrometer.png",  	liquids_pointable = false,  	range = 2.5,  | 
