Closed lijspoop closed 2 weeks ago
Thanks, I believe it's fixed in a unstable branch. But at least we can track it here now. Good catch!
I'll try to get this fixed in next update.
Long term hoping to add translation injection to parse the json file to see if a dollar sign is missing for something that looks like a key.
Would be a "build" test.
The same mistake
And while reviewing the code, I had two questions:
I think that line 215 can be deleted (by removing the unnecessary creation of a variable), and it should turn out something like this:
var piece = prefab.AddComponent<Piece>();
piece.m_name = $"$mb_sail_{sailCount}";
piece.m_description = $"$mb_sail_{sailCount}_desc";
piece.m_placeEffect = LoadValheimAssets.woodFloorPiece.m_placeEffect;
RegisterCustomSail
) of creating a sail, moreover, it is not found anywhere in the release?
https://github.com/zolantris/ValheimMods/blob/6ea46882655e5264d8e48eed2c23ec0676bee702/src/ValheimVehicles/ValheimVehicles.Prefabs/Registry/SailPrefabs.cs#L174-L175Most likely, this can be seen somewhere else in the code, but it doesn't hurt to ask at least about it.
Long term hoping to add translation injection to parse the json file to see if a dollar sign is missing for something that looks like a key.
Would be a "build" test.
Is it possible to do it differently? For example, generate a translation file when "build".
try using this method to avoid something like this; it adds a $
symbol to the beginning of a translation key if it isn't already there. For example, the string "valheim_vehicles_ram_stake valheim_vehicles_material_tier3"
will be transformed into "$valheim_vehicles_ram_stake $valheim_vehicles_material_tier3"
.
public static string NormalizeTranslationKeys(string localizableString)
{
return new Regex(@"((?<!\$)\b\w+_\w+\b)").Replace(localizableString, match => "$" + match.Value);
}
for example, you can use it here: https://github.com/zolantris/ValheimMods/blob/ed67ed1f3d93c70bafdd4e0f55f16d34011fa44b/src/ValheimVehicles/ValheimVehicles.Prefabs/PrefabRegistryHelpers.cs#L20-L25
by doing this:
public struct PieceData
{
private string _name;
private string _description;
public string Name
{
get => _name;
set => _name = NormalizeTranslationKeys(value);
}
public string Description
{
get => _description;
set => _description = NormalizeTranslationKeys(value);
}
public Sprite Icon;
}
https://github.com/zolantris/ValheimMods/blob/6ea46882655e5264d8e48eed2c23ec0676bee702/src/ValheimVehicles/ValheimVehicles.Prefabs/PrefabRegistryHelpers.cs#L309
Missing
$
at the beginning of the string$"$valheim_vehicles_hull_center_desc {ironMatDesc}"