Support locale in guide hypertext

This commit is contained in:
2025-11-24 21:23:16 +01:00
parent 69c8355ecb
commit 85b5d5808a

View File

@@ -89,9 +89,9 @@ local pages={
icon=industrialtest.elementKeys.paper,
content={
[[
<big>Introduction</big>
<big>||Introduction||</big>
<left>
IndustrialTest implements finite power functionality which can be used to perform various tasks using generators and consumers. Such features are not a new thing in Luanti, as there are older mods which do that already. This mod, however, proves to be more flexible.
||IndustrialTest implements finite power functionality which can be used to perform various tasks using generators and consumers. Such features are not a new thing in Luanti, as there are older mods which do that already. This mod, however, proves to be more flexible.||
</left>
<img name="industrialtest_guide_introduction.png" width="{{IMAGE_WIDTH}}">
]]
@@ -104,12 +104,12 @@ local pages={
icon="industrialtest:insulated_copper_cable",
content={
[[
<big>Electrical network</big>
<big>||Electrical network||</big>
<left>
In order to attach electricity consumers to power sources (like generators, batteries, further just called generators) electrical network is used. Consumers can get connected either directly to generators or through various cables. Each generator can output certain voltage (this is actually amperage, however since this mod doesn't simulate electricity accurately, it's called voltage), the same situation is for consumers as they can only handle up to certain voltage.
Figure 1 shows voltage levels present in this mod.
If voltage is too high for cable it will melt without dropping anything while consumer will explode also without dropping anything and possibly destroying terrain around. Power capacity is measured in EU (Energy Units) and the voltage is EU/update.
Picture 1 shows environment after consumer explosion.
||In order to attach electricity consumers to power sources (like generators, batteries, further just called generators) electrical network is used. Consumers can get connected either directly to generators or through various cables. Each generator can output certain voltage (this is actually amperage, however since this mod doesn't simulate electricity accurately, it's called voltage), the same situation is for consumers as they can only handle up to certain voltage.||
||Figure 1 shows voltage levels present in this mod.||
||If voltage is too high for cable it will melt without dropping anything while consumer will explode also without dropping anything and possibly destroying terrain around. Power capacity is measured in EU (Energy Units) and the voltage is EU/update.||
||Picture 1 shows environment after consumer explosion.||
</left>
]],
createTable({
@@ -143,10 +143,10 @@ local pages={
"163800",
"Glass Fibre"
}
},true,"Figure 1. Voltage levels and respective cables"),
},true,S("Figure 1. Voltage levels and respective cables")),
[[
<img name="industrialtest_guide_explosion.png" width="{{IMAGE_WIDTH}}">
<left>Picture 1. Environment after consumer explosion</left>
<left>||Picture 1. Environment after consumer explosion||</left>
]]
}
},
@@ -157,9 +157,9 @@ local pages={
icon="industrialtest:cable_former",
content={
[[
<big>Cable Former</big>
<big>||Cable Former||</big>
<left>
Cable Former can be used to produce cables with higher material efficiency. It can, however, only produce cables from metals so for example <item name="industrialtest:glass_fibre_cable" height="{{ITEM_HEIGHT}}"> <b>Glass Fibre Cable</b> can't be produced in it.
||Cable Former can be used to produce cables with higher material efficiency. It can, however, only produce cables from metals so for example <item name="industrialtest:glass_fibre_cable" height="{{ITEM_HEIGHT}}"> <b>Glass Fibre Cable</b> can't be produced in it.||
</left>
]],
createMachineInformationTable({
@@ -182,7 +182,7 @@ local pages={
},S("Cable Former")),
[[
<img name="industrialtest_guide_cable_former.png" width="{{IMAGE_WIDTH}}">
<left>Picture 1. Cable Former running</left>
<left>||Picture 1. Cable Former running||</left>
]]
}
},
@@ -193,9 +193,9 @@ local pages={
icon="industrialtest:canning_machine",
content={
[[
<big>Canning Machine</big>
<big>||Canning Machine||</big>
<left>
Canning Machine is used to move certain fluid from one item to another. The common usage is to refill fuel in <item name="industrialtest:jetpack_v" height="{{ITEM_HEIGHT}}"> <b>Jetpack</b> or <item name="industrialtest:fuel_can" height="{{ITEM_HEIGHT}}"> <b>Fuel Can</b>.
||Canning Machine is used to move certain fluid from one item to another. The common usage is to refill fuel in <item name="industrialtest:jetpack_v" height="{{ITEM_HEIGHT}}"> <b>Jetpack</b> or <item name="industrialtest:fuel_can" height="{{ITEM_HEIGHT}}"> <b>Fuel Can</b>.||
</left>
]],
createMachineInformationTable({
@@ -218,7 +218,7 @@ local pages={
},S("Canning Machine")),
[[
<img name="industrialtest_guide_canning_machine.png" width="{{IMAGE_WIDTH}}">
<left>Picture 1. Canning Machine refilling <item name="industrialtest:fuel_can" height="{{ITEM_HEIGHT}}"> <b>Fuel Can</b> with fuel from <item name="industrialtest:coalfuel_cell" height="{{ITEM_HEIGHT}}"> <b>Coalfuel Cell</b></left>
<left>||Picture 1. Canning Machine refilling <item name="industrialtest:fuel_can" height="{{ITEM_HEIGHT}}"> <b>Fuel Can</b> with fuel from <item name="industrialtest:coalfuel_cell" height="{{ITEM_HEIGHT}}"> <b>Coalfuel Cell</b>||</left>
]]
}
},
@@ -229,9 +229,9 @@ local pages={
icon="industrialtest:compressor",
content={
[[
<big>Compressor</big>
<big>||Compressor||</big>
<left>
Compressor as the name suggests is used to compress various materials. Mostly required to produce items for crafting other items.
||Compressor as the name suggests is used to compress various materials. Mostly required to produce items for crafting other items.||
</left>
]],
createMachineInformationTable({
@@ -258,7 +258,7 @@ local pages={
},S("Compressor")),
[[
<img name="industrialtest_guide_compressor.png" width="{{IMAGE_WIDTH}}">
<left>Picture 1. Compressor compressing <item name="industrialtest:plantball" height="{{ITEM_HEIGHT}}"> <b>Plantball</b> into <item name="industrialtest:compressed_plantball" height="{{ITEM_HEIGHT}}"> <b>Compressed Plantball</b></left>
<left>||Picture 1. Compressor compressing <item name="industrialtest:plantball" height="{{ITEM_HEIGHT}}"> <b>Plantball</b> into <item name="industrialtest:compressed_plantball" height="{{ITEM_HEIGHT}}"> <b>Compressed Plantball</b>||</left>
]]
}
},
@@ -269,9 +269,9 @@ local pages={
icon="industrialtest:electric_furnace",
content={
[[
<big>Electric Furnace</big>
<big>||Electric Furnace||</big>
<left>
Electric Furnace like regular furnace can be used to smelt items. The difference is that Electric Furnace is slightly faster even without any upgrades and, well, it's electric so it doesn't require fuel.
||Electric Furnace like regular furnace can be used to smelt items. The difference is that Electric Furnace is slightly faster even without any upgrades and, well, it's electric so it doesn't require fuel.||
</left>
]],
createMachineInformationTable({
@@ -298,16 +298,22 @@ local pages={
},S("Electric Furnace")),
[[
<img name="industrialtest_guide_electric_furnace.png" width="{{IMAGE_WIDTH}}">
<left>Picture 1. Electric Furnace smelting <item name="industrialtest:iron_dust" height="{{ITEM_HEIGHT}}"> <b>Iron Dust</b> into <item name="{{elementKeyIronIngot}}" height="{{ITEM_HEIGHT}}"> <b>Iron Ingot</b></left>
<left>||Picture 1. Electric Furnace smelting <item name="industrialtest:iron_dust" height="{{ITEM_HEIGHT}}"> <b>Iron Dust</b> into <item name="{{elementKeyIronIngot}}" height="{{ITEM_HEIGHT}}"> <b>Iron Ingot</b>||</left>
]]
}
}
}
local function preprocessHypertext(content,vars)
-- Find and replace strings which should be translated, this pattern matches any string that doesn't include | which is contained within || at both ends
content=string.gsub(content,"||([^|]+)||",function(sourceString)
return S(sourceString)
end)
for key,value in pairs(vars) do
content=string.gsub(content,string.format("{{%s}}",key),value)
end
return content
end