feat(text): item, piece and creature names come from translation files

The mod's own items, build pieces and summoned creatures now carry
$rov_item_, $rov_piece_ and $rov_creature_ tokens for their names and
descriptions, and items.json holds the texts in English and Italian.
Valheim localizes these fields wherever it shows them: tooltips, hover
texts, messages, the build menu.

Where a name doubles as an identifier, both sides use the same constant,
so the comparisons still hold. The Aswid foods keep their prefix as a
constant for the refinery's check and now name the creature with its
vanilla token, so "Boar" translates too. The Furling crops get one whole
description per crop instead of an English sentence with the metal dropped
in. The Race Menu Ward's panel title is a mod UI Text, so it reads the
translation directly.

Saves are unaffected: items and eaten foods are stored by prefab name.
The Sverm hive's goods stay for the merchant step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-26 19:58:53 +02:00
commit b177c89c71
34 changed files with 405 additions and 142 deletions

View file

@ -65,27 +65,27 @@ namespace RacesOfValheim
{
new MetalCrop
{
Metal = "Copper", FlaxName = "CopperFlax", FlaxDisplay = "Copper Flax",
DustName = "CopperDust", DustDisplay = "Copper Dust",
Metal = "Copper", FlaxName = "CopperFlax", FlaxDisplay = "$rov_item_furling_copperflax_name",
DustName = "CopperDust", DustDisplay = "$rov_item_furling_copperdust_name",
PickableName = "Pickable_CopperFlax", SaplingName = "sapling_copperflax",
SaplingDisplay = "Copper Flax", OrePrefab = "CopperOre",
SaplingDisplay = "$rov_piece_furling_copperflaxsapling_name", OrePrefab = "CopperOre",
Tint = new Color(0.72f, 0.45f, 0.20f, 1f),
},
new MetalCrop
{
Metal = "Tin", FlaxName = "TinFlax", FlaxDisplay = "Tin Flax",
DustName = "TinDust", DustDisplay = "Tin Dust",
Metal = "Tin", FlaxName = "TinFlax", FlaxDisplay = "$rov_item_furling_tinflax_name",
DustName = "TinDust", DustDisplay = "$rov_item_furling_tindust_name",
PickableName = "Pickable_TinFlax", SaplingName = "sapling_tinflax",
SaplingDisplay = "Tin Flax", OrePrefab = "TinOre",
SaplingDisplay = "$rov_piece_furling_tinflaxsapling_name", OrePrefab = "TinOre",
Tint = new Color(0.80f, 0.82f, 0.85f, 1f),
},
new MetalCrop
{
Metal = "Iron", FlaxName = "IronFlax", FlaxDisplay = "Iron Flax",
DustName = "IronDust", DustDisplay = "Iron Dust",
Metal = "Iron", FlaxName = "IronFlax", FlaxDisplay = "$rov_item_furling_ironflax_name",
DustName = "IronDust", DustDisplay = "$rov_item_furling_irondust_name",
PickableName = "Pickable_IronFlax", SaplingName = "sapling_ironflax",
// Iron's raw form is IronScrap, not "IronOre" - there is no IronOre prefab.
SaplingDisplay = "Iron Flax", OrePrefab = "IronScrap",
SaplingDisplay = "$rov_piece_furling_ironflaxsapling_name", OrePrefab = "IronScrap",
Tint = new Color(0.35f, 0.36f, 0.38f, 1f),
},
};
@ -104,18 +104,29 @@ namespace RacesOfValheim
{
new RockBerry
{
BerryName = "Stoneberry", BerryDisplay = "Stoneberry",
BushName = "StoneberryBush", BushDisplay = "Stoneberry Bush",
BerryName = "Stoneberry", BerryDisplay = "$rov_item_furling_stoneberry_name",
BushName = "StoneberryBush", BushDisplay = "$rov_piece_furling_stoneberrybush_name",
YieldPrefab = "Stone", Tint = new Color(0.55f, 0.55f, 0.55f, 1f),
},
new RockBerry
{
BerryName = "Flintberry", BerryDisplay = "Flintberry",
BushName = "FlintberryBush", BushDisplay = "Flintberry Bush",
BerryName = "Flintberry", BerryDisplay = "$rov_item_furling_flintberry_name",
BushName = "FlintberryBush", BushDisplay = "$rov_piece_furling_flintberrybush_name",
YieldPrefab = "Flint", Tint = new Color(0.30f, 0.32f, 0.35f, 1f),
},
};
/// <summary>
/// The description token that goes with a name token: "$rov_item_furling_tinflax_name" gives
/// "$rov_item_furling_tinflax_desc". One whole sentence per crop in the translation files,
/// rather than one sentence with the metal dropped in, so a translator can decline the metal
/// or move it wherever their language wants it.
/// </summary>
private static string DescriptionFor(string nameToken)
{
return nameToken.EndsWith("_name") ? nameToken.Substring(0, nameToken.Length - 5) + "_desc" : nameToken;
}
public static void Register()
{
foreach (MetalCrop crop in Crops) RegisterCrop(crop);
@ -151,8 +162,7 @@ namespace RacesOfValheim
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
shared.m_name = crop.FlaxDisplay;
shared.m_description = $"Flax grown in {crop.Metal.ToLowerInvariant()}-poisoned soil, and it took. " +
"Useless as cloth. Grind it and see.";
shared.m_description = DescriptionFor(crop.FlaxDisplay);
// Teleportable is inherited from Flax and left alone on purpose: the flax travels, the
// dust does not. That asymmetry is the whole point of the chain.
@ -177,8 +187,7 @@ namespace RacesOfValheim
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
shared.m_name = crop.DustDisplay;
shared.m_description = $"A sack of {crop.Metal.ToLowerInvariant()} ground fine. " +
"A furnace cannot tell it from ore, and it will not go through a portal either.";
shared.m_description = DescriptionFor(crop.DustDisplay);
shared.m_itemType = ItemDrop.ItemData.ItemType.Material;
shared.m_food = 0f;
shared.m_foodStamina = 0f;
@ -280,7 +289,7 @@ namespace RacesOfValheim
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
{
Name = crop.SaplingDisplay,
Description = $"Plant it and it grows more {crop.FlaxDisplay}.",
Description = DescriptionFor(crop.SaplingDisplay),
PieceTable = PieceTables.Cultivator,
Requirements = new[] { new RequirementConfig(crop.FlaxName, 1, 0, true) },
}));
@ -310,7 +319,7 @@ namespace RacesOfValheim
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
shared.m_name = berry.BerryDisplay;
shared.m_description = $"Not a berry, whatever it looks like. Bury one and a {berry.YieldPrefab.ToLowerInvariant()}-bearing bush comes up.";
shared.m_description = DescriptionFor(berry.BerryDisplay);
// Inedible, as designed. Material with every food value at zero also keeps it clear of
// the Trenta's vegan check and of the Aswid/Skeleton food gates, all three of which only
@ -385,7 +394,7 @@ namespace RacesOfValheim
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
{
Name = berry.BushDisplay,
Description = $"Yields {berry.YieldPrefab.ToLowerInvariant()}, and keeps yielding it.",
Description = DescriptionFor(berry.BushDisplay),
PieceTable = PieceTables.Cultivator,
// The one thing that was actually missing the first time round.
Icon = BorrowIcon(berry.YieldPrefab),