feat(text): on-screen messages come from translation files

Every message the mod puts in the middle or corner of the screen now reads
its text through ModText.Get, and messages.json holds 191 texts in English
and Italian. Values computed in code become $1, $2 in the text, so a
translator can put them wherever the sentence needs them. Branching
messages get one key per branch.

A few messages travel through a field before they are shown: thralls'
refusals and the building limits now hold a token or key there. Boss and
form names inside messages use tokens too, the bosses the game's own, so
"The Elder" arrives translated.

ModText.Get now localizes each argument before inserting it. A token
argument left for a later pass ran into the text after it: "$1's power"
became the unknown token "enemy_eikthyr's".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-26 20:30:03 +02:00
commit b0d18b0654
61 changed files with 606 additions and 200 deletions

View file

@ -257,7 +257,7 @@ namespace RacesOfValheim
float cost = Mathf.Min(STAMINA_PER_PROJECTILE * projCount, MAX_VOLLEY_STAMINA);
if (!Player.m_localPlayer.HaveStamina(cost))
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_not_enough_stamina"));
return false;
}
Player.m_localPlayer.UseStamina(cost);

View file

@ -306,21 +306,21 @@ namespace RacesOfValheim
if (!SkadiRace.IsLocalSkadi())
{
player.Message(MessageHud.MessageType.Center, "The stone does not answer to you.");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_stone_does_not_answer"));
return false;
}
if (BossProgressionManager.GetCurrentProgressionState() < ModerProgressionState)
{
player.Message(MessageHud.MessageType.Center,
"The tear is cold. Nothing wakes in the stone until the mountain's queen has fallen.");
ModText.Get("rov_msg_skadi_tear_cold_nothing_wakes_stone"));
return false;
}
CraftingStation station = FindStonecutter(position);
if (station == null)
{
player.Message(MessageHud.MessageType.Center, "It needs a stonecutter to be cut at.");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_needs_stonecutter_cut_at"));
return false;
}
@ -328,7 +328,7 @@ namespace RacesOfValheim
if (bound >= MaxPerStation)
{
player.Message(MessageHud.MessageType.Center,
$"That stonecutter already holds {bound}. It will not hold more.");
ModText.Get("rov_msg_skadi_that_stonecutter_already_holds_will", bound));
return false;
}
@ -336,7 +336,7 @@ namespace RacesOfValheim
if (nearby >= MaxInArea)
{
player.Message(MessageHud.MessageType.Center,
$"There are already {nearby} of these within a day's walk. The stone is spent.");
ModText.Get("rov_msg_skadi_there_are_already_these_within", nearby));
return false;
}

View file

@ -181,7 +181,7 @@ namespace RacesOfValheim
Vector3.Distance(Player.m_localPlayer.transform.position, transform.position) < 30f)
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center,
"The stonecutter is gone. What it cut will not outlast it by long.");
ModText.Get("rov_msg_skadi_stonecutter_gone_what_cut_will"));
}
}

View file

@ -246,7 +246,7 @@ namespace RacesOfValheim
if (isTransformed && formExpireTime > 0f && Time.time >= formExpireTime)
{
formExpireTime = 0f;
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Your dragon form fades.");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_fades"));
StartCoroutine(RevertToHumanRoutine());
return;
}
@ -265,7 +265,7 @@ namespace RacesOfValheim
DumpPrefabDebugInfo("Dragon");
DumpPrefabDebugInfo("Hatchling");
DumpPrefabDebugInfo("Fader");
if (Player.m_localPlayer != null) Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Dumped Dragon/Drake/Fader debug info to console!");
if (Player.m_localPlayer != null) Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dumped_dragon_drake_fader_debug"));
}
}
@ -438,7 +438,7 @@ namespace RacesOfValheim
// the Mistlands onward, so the old HaveEitr gate left it unusable for five tiers.
if (!Player.m_localPlayer.HaveStamina(SPELL_STAMINA_COST))
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_not_enough_stamina"));
return;
}
@ -710,7 +710,7 @@ namespace RacesOfValheim
if (remaining < 0) remaining = 0;
int rMin = Mathf.FloorToInt(remaining / 60f);
int rSec = Mathf.FloorToInt(remaining % 60f);
Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"Dragon Form is on cooldown ({rMin}:{rSec:00}).");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_cooldown", rMin, (rSec).ToString("00")));
return;
}
}
@ -891,9 +891,9 @@ namespace RacesOfValheim
DrakeFormBehavior behavior = currentTransformation.AddComponent<DrakeFormBehavior>();
behavior.Initialize(rules);
if (prefabName == "Hatchling") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Drake!");
else if (prefabName == "Dragon") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Moder!");
else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Fader!");
if (prefabName == "Hatchling") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_drake"));
else if (prefabName == "Dragon") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_moder"));
else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_fader"));
isTransformed = true;
StartFormTimer(rules);
@ -943,7 +943,7 @@ namespace RacesOfValheim
isTransformed = false;
formExpireTime = 0f;
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiForm".GetStableHashCode(), true);
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You returned to human form.");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_returned_human_form"));
if (activeRules != null && activeRules.CooldownMinutes > 0)
{