Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Aug 18, 2024
1 parent 1f18908 commit 7859285
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Content.Shared/Prototypes/LocalizedPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ public abstract class LocalizedPrototype : IPrototype
[IdDataField]
public string ID { get; } = default!;

public const string LocFormat = "{type}-{ID}-{field}";
public const string LocFormat = "{0}-{1}-{2}";

/// <summary>The localization string for the name of this prototype</summary>
public string NameLoc => ToLocalizationString("name");
/// <summary>The localized string for the name of prototype</summary>
public string Name => Loc.GetString(NameLoc);

/// <summary>
/// Returns an Loc string using the <see cref="field"/> as the 'property'.
/// Given `desc` it will return `this-prototype-PrototypeId-desc`.
/// </summary>
public string ToLocalizationString(string field)
{
// Get the ID of the proto Type
Expand All @@ -26,12 +30,6 @@ public string ToLocalizationString(string field)
// Replace every uppercase letter with a dash and the lowercase letter
type = type.Aggregate("", (current, c) => current + (char.IsUpper(c) ? "-" + char.ToLowerInvariant(c) : c.ToString()));

// Replace the placeholders with the actual values
var t = LocFormat
.Replace("{type}", type)
.Replace("{ID}", ID)
.Replace("{field}", field);

return t;
return string.Format(LocFormat, type, ID, field);
}
}

0 comments on commit 7859285

Please sign in to comment.