RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Custom type serializer for localized strings

Open Macoron opened this issue 3 years ago • 0 comments
trafficstars

So right now we do this for localized strings in prototypes and components:

[DataField("name", required: true)]
private string Name { get; } = default!;

[ViewVariables(VVAccess.ReadOnly)]
public string LocalizedName => Loc.GetString(Name);

That could be replaced by:

[DataField("name", customTypeSerializer: typeof(LocalizedStringSerializer))]
public string Name = default!;

or for list:

[DataField("name", customTypeSerializer: typeof(LocalizedStringListSerializer))]
public List<string> Names = new();

We can even run ingegration test, to see if content has all localized strings in english .ftl files.

Macoron avatar May 04 '22 18:05 Macoron