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

@ -53,7 +53,7 @@ namespace RacesOfValheim
public float m_homeCheckRange = 20f;
/// <summary>Shown in the refusal when a station is not this player's to command.</summary>
public string m_refusalMessage = "It does not answer to you.";
public string m_refusalMessage = "$rov_msg_thrall_refusal_default";
/// <summary>
/// How many thralls of OTHER kinds, from the same station, come along when this one is
@ -298,7 +298,7 @@ namespace RacesOfValheim
{
m_monsterAI.SetFollowTarget(null);
GoHome();
if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} returns.");
if (announce) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_returns", m_character.m_name));
return true;
}
@ -308,7 +308,7 @@ namespace RacesOfValheim
{
if (announce)
{
player.Message(MessageHud.MessageType.Center, $"Only {m_maxFollowers} may walk with you.");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_only_may_walk_with", m_maxFollowers));
}
return false;
}
@ -323,7 +323,7 @@ namespace RacesOfValheim
if (m_ai != null) m_ai.ResetPatrolPoint();
m_monsterAI.SetFollowTarget(player.gameObject);
if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} follows.");
if (announce) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_follows", m_character.m_name));
return true;
}
@ -355,9 +355,7 @@ namespace RacesOfValheim
if (other.SetFollowing(player, follow, announce: false)) taken++;
}
player.Message(MessageHud.MessageType.Center, follow
? $"{m_character.m_name} rises with {taken}."
: $"{m_character.m_name} stands down with {taken}.");
player.Message(MessageHud.MessageType.Center, (follow ? ModText.Get("rov_msg_thrall_rises_with", m_character.m_name, taken) : ModText.Get("rov_msg_thrall_stands_down_with", m_character.m_name, taken)));
}
private static int CountFollowers(Player player, string kind)
@ -445,12 +443,12 @@ namespace RacesOfValheim
if (came > 0)
{
player.Message(MessageHud.MessageType.Center, $"{came} answer the call.");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_answer_call", came));
}
else if (refused > 0)
{
// The only way SetFollowing refuses a thrall that may be commanded is the cap.
player.Message(MessageHud.MessageType.Center, "No more may walk with you.");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_no_more_may_walk_with"));
}
}